From: William James Date: 2005-10-21T09:51:59+09:00 Subject: Re: Functional with Ruby Andreas Semt wrote: > Hello list, > > here a really simple Haskell function, which sums all elements of a list > (from the book "The Haskell School of Expression"): > -------------------------------- > listSum [] = 0 > listSum (x : xs) = x + listSum xs > -------------------------------- > > Which is the best way to say it in Ruby (functional style)? Don't use > 'enum.inject', please! > > > Thanks for your thoughts. > Greetings, > Andreas Semt irb(main):011:0> def sum(a,i) irb(main):012:1> i end => nil irb(main):014:0> sum([1,3,5,7,9], 0) => 25