MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: simple problem with Map?!?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49485] RE: [mg49480] simple problem with Map?!?
  • From: "Florian Jaccard" <florian.jaccard at eiaj.ch>
  • Date: Thu, 22 Jul 2004 02:44:49 -0400 (EDT)
  • Reply-to: <florian.jaccard at eiaj.ch>
  • Sender: owner-wri-mathgroup at wolfram.com

Plus@@# evalautes the sum of a single element of d0... so #/Plus@@# always
gives 1 !

You must write :

pppp = N[# / (Plus @@ d0)] & /@ d0

regards

F.Jaccard

-----Message d'origine-----
De : Relishguy [mailto:relishguy at pluggedin.org]
Envoyé : mer., 21. juillet 2004 12:41
À : mathgroup at smc.vnet.net
Objet : [mg49480] simple problem with Map?!?


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..




  • Prev by Date: RE: Applying my function to elements of a vector
  • Next by Date: RE: Applying my function to elements of a vector
  • Previous by thread: Re: RE: simple problem with Map?!?
  • Next by thread: Re: simple problem with Map?!?