From: Matias Surdi Date: 2005-12-15T21:13:56+09:00 Subject: Re: ruby beats them all Jeff Wood escribi�: > Nice. > > On 12/14/05, Christian Neukirchen wrote: > >>"Peter Ertl" 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 http://chneukirchen.org >> >> > > > > -- > "Remember. Understand. Believe. Yield! -> http://ruby-lang.org" > > Jeff Wood > You're all crazy.... :-) (in the good sense... ;-) )