Jeff Wood escribióº > Nice. > > On 12/14/05, Christian Neukirchen <chneukirchen / gmail.com> wrote: > >>"Peter Ertl" <pertl / gmx.org> writes: >> >> >>>that why I love ruby (and functional languages in general) >>> >>>def fibonacci(n) >>> a, b = 1, 1 >>> n.times do >>> a, b = b, a + b >>> end >>> a >>>end >> >>That's not functional... >> >>How about really doing it functional? >> >>def fib(n) >> (1..n-2).inject([1, 1]) { |(a, b), n| [b, a+b] }.last >>end >> >>:) >> >> >>>elegance beats ignorance (ruby vs. java) >> >>-- >>Christian Neukirchen <chneukirchen / gmail.com> http://chneukirchen.org >> >> > > > > -- > "Remember. Understand. Believe. Yield! -> http://ruby-lang.org" > > Jeff Wood > You're all crazy.... :-) (in the good sense... ;-) )