From: Jeff Wood Date: 2005-12-15T04:55:38+09:00 Subject: Re: ruby beats them all ------=_Part_4861_5240752.1134590130001 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 =3D 1, 1 > > n.times do > > a, b =3D 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 ------=_Part_4861_5240752.1134590130001--