Re: best cumulative sum
- From: Robert Kern <robert.kern@xxxxxxxxx>
- Date: Sun, 20 Nov 2005 22:24:21 -0800
Erik Max Francis wrote:
> Micah Elliott wrote:
>
>>On Nov 21, David Isaac wrote:
>>>What's the good way to produce a cumulative sum?
>>
>>>>>import operator
>>>>>x = 1,2,3
>>>>>reduce(operator.add, x)
>>
>>6
>
> Or just sum(x).
That just gives you the tail end. The OP asked for a cumulative sum;
that is, a list with all of the intermediate sums, too.
--
Robert Kern
robert.kern@xxxxxxxxx
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
.
- References:
- best cumulative sum
- From: David Isaac
- Re: best cumulative sum
- From: Micah Elliott
- Re: best cumulative sum
- From: Erik Max Francis
- best cumulative sum
- Prev by Date: Re: ownership problem?
- Next by Date: Re: best cumulative sum
- Previous by thread: Re: best cumulative sum
- Next by thread: Re: best cumulative sum
- Index(es):
Relevant Pages
|