Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Sum of list elements

  • To: mathgroup at
  • 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$>
  • Reply-to: spam at (Per Rønne)
  • Sender: owner-wri-mathgroup at

Florian Jaccard <florian.jaccard at> 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

  • Prev by Date: Re: Sum of list elements
  • Next by Date: Re: A question about function
  • Previous by thread: Re: Sum of list elements
  • Next by thread: A question about function