Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

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: [mg54459] Re: computing cumulative sum for list
  • From: Peter Pein <petsie at arcor.de>
  • Date: Sun, 20 Feb 2005 00:11:32 -0500 (EST)
  • References: <cv6s22$6kf$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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
> 

Rest[FoldList[#1+#2&,0,Range[5]]]

-- 
Peter Pein
Berlin


  • Prev by Date: Re: Perplexed by the behavior of NonlinearFit in Mathematica ver 4.2 vs 5.1
  • Next by Date: Re: graphing in Mathematica
  • Previous by thread: Re: computing cumulative sum for list
  • Next by thread: Re: computing cumulative sum for list