[Haskell-beginners] Re: Understanding cached fibonnacci function
Patrick LeBoutillier
patl at cpan.org
Fri Jan 30 11:41:29 EST 2009
>> fibs = fix ((0:) . scanl (+) 1)
>
> I don't like that one. My favorite is the following, because it's
> short, concise and still very comprehensible:
>
> import Data.Function
>
> fibs :: Num i => [i]
> fibs = fix (\r x y -> x : r y (x+y)) 0 1
Can someone please explain this one? I can't seem to figure out what
'fix' does (the definition in the documentation is a bit to
mathematically inclined for me...).
Thanks,
Patrick
--
=====================
Patrick LeBoutillier
Rosemère, Québec, Canada
More information about the Beginners
mailing list