
30 Jan
2009
30 Jan
'09
11:41 a.m.
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