MathGroup Archive 2005

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

Search the Archive

Re: computing cumulative sum for list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54525] Re: [mg54367] computing cumulative sum for list
  • From: János <janos.lobb at yale.edu>
  • Date: Tue, 22 Feb 2005 04:23:53 -0500 (EST)
  • References: <200502190732.CAA06098@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

One way to do it is:

In[1]:=
lst = {1, 2, 3, 4, 5}
Out[1]=
{1, 2, 3, 4, 5}

In[8]:=
Table[Total[Take[lst, i]],
   {i, 1, Length[lst]}]
Out[8]=
{1, 3, 6, 10, 15}

On Feb 19, 2005, at 2:32 AM, Uwe Ziegenhagen wrote:

> Hello,
> I would like to compute the cumulative sum for a list, but do not find
> the command.
> For
> {1,2,3,4,5}
> I would like to get
> {1,3,4,10,15}
> Is there nothing builtin in Mathematica? I already looked in lists and
> matrices and Google...
> Uwe
> -- 
> mail to newsgroup at ziegenhagen.info is read only from time to time. If
> you need an urgent answer, google for me.


  • Prev by Date: Re: Most plotting not working...?
  • Next by Date: Re: problems plotting a derivative
  • Previous by thread: Re: computing cumulative sum for list
  • Next by thread: Re: computing cumulative sum for list