Re: Sum of list elements
- To: mathgroup at smc.vnet.net
- Subject: [mg49320] Re: Sum of list elements
- From: spam at husumtoften.invalid (Per Rønne)
- Date: Wed, 14 Jul 2004 07:29:25 -0400 (EDT)
- References: <cd0bgd$aik$1@smc.vnet.net>
- Reply-to: spam at husumtoften.dk (Per Rønne)
- Sender: owner-wri-mathgroup at wolfram.com
Florian Jaccard <florian.jaccard at eiaj.ch> wrote: > Is this what you want ? > > In[193]:= > liste={2,2,1}; > > In[195]:= > Plus@@liste > > Out[195]= > 5 > > In[196]:= > 1/Plus@@liste*liste > > Out[196]= > {2/5, 2/5, 1/5} Thank you very much to you and Ravinder Kumar B. Instead, I was trying with something like: sum[l_] := Module[ {c = 0}, Do[c = c + l[[i]], {i, Length[l]}]; Return[c]] But of course the use of Apply [@@] is a better solution. BTW, I don't understand why threads in this newsgroup are grouped so loosely. It can be seen in MacSOUP, in the tree window, that there should be missing answers? -- Per Erik Rønne