From: Matt Silberstein Date: 2005-12-20T03:47:47+09:00 Subject: Re: ruby beats them all On 15 Dec 2005 07:17:22 -0800, in comp.lang.ruby , "jwesley" in <1134659842.025061.195640@z14g2000cwz.googlegroups.com> wrote: >If Ruby properly handled tail-recursion, then the "accumulator passing" >style work for any number: > >def fib n > fib_helper( n, 1, 1) >end > >def fib_helper n, next_val, val > n < 1 ? val : fib_helper( n-1, next_val + val, next_val) >end > >the above code (in accumulator-passing style) only works through about >n=1300 for me. It is grossly inefficient to implement fib as recursive even if it seems like clever code. -- Matt Silberstein Do something today about the Darfur Genocide http://www.beawitness.org http://www.darfurgenocide.org http://www.savedarfur.org "Darfur: A Genocide We can Stop"