Re: computing cumulative sum for list
- To: mathgroup at smc.vnet.net
- Subject: [mg54425] Re: computing cumulative sum for list
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sun, 20 Feb 2005 00:09:38 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 2/19/05 at 2:32 AM, newsgroup at ziegenhagen.info (Uwe Ziegenhagen) wrote: >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} In[1]= Rest@FoldList[Plus, 0, Range@5] Out[1]= {1, 3, 6, 10, 15} alternatively In[2]:= a = Range@5; FoldList[Plus, First@a, Rest@a] Out[3]= {1, 3, 6, 10, 15} -- To reply via email subtract one hundred and four