On Monday 22 September 2008 23:26:34 Martin DeMello wrote:
> On Mon, Sep 22, 2008 at 2:07 PM, Matthew Moss <matthew.moss / gmail.com> 
wrote:
> > Too many solvers not providing additional problems!
> >
> > Here's another... Assuming you have an array of numeric data, write a
> > method that returns an array of progressive sums. That is:
> >
> >    prog_sum( [1, 5, 13, -6, 20] ) =>  [1, 6, 19, 13, 33]
>
> def prog_sum(ary)
>   ary.inject([0, []]) {|(s, a), i| [s+i, a<<(s+i)]}.last
> end

And what about
def prog_sum(array)
  sum = 0; array.collect { |e| sum+=e }
end