Re: simple problem with Map?!?
- To: mathgroup at smc.vnet.net
- Subject: [mg49491] Re: [mg49480] simple problem with Map?!?
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Thu, 22 Jul 2004 02:44:57 -0400 (EDT)
- References: <200407211040.GAA07884@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 21 Jul 2004, at 19:40, Relishguy wrote:
> *This message was transferred with a trial version of CommuniGate(tm)
> Pro*
> I do not understand why the last evaluation ends up screwed:
>
> In[1]:= d0 = {30,60,180,60,30};
>
> In[2]:= tt = Plus @@ d0
> Out[2]= 360
>
> In[3]:= pp = N[d0 / tt]
> Out[3]= {0.0833333,0.166667,0.5,0.166667,0.0833333}
>
> In[4]:= ppp = N[d0 / (Plus @@ d0)]
> Out[4]= {0.0833333,0.166667,0.5,0.166667,0.0833333}
>
> In[5]:= pppp = N[# / (Plus @@ #)]& /@ d0
> Out[5]= {1.,1.,1.,1.,1.}
>
> Can anyone explain this simply? Do I need Hold[] or Evaluate[]
> somewhere?
>
> TIA.
>
> Regards..
Hold and Evaluate have nothing to do here. Neither does Map. Presumably
what you mean is:
d0={30,60,180,60,30};
pppp=N[#/(Plus@@#)]&@d0
{0.0833333,0.166667,0.5,0.166667,0.0833333}
Andrzej Kozlowski
Chiba, Japan
http://www.mimuw.edu.pl/~akoz/
- References:
- simple problem with Map?!?
- From: relishguy@pluggedin.org (Relishguy)
- simple problem with Map?!?