
30 Jan
2009
30 Jan
'09
9:59 a.m.
Daniel Fischer
Not to forget the marvellous
import Control.Monad.Fix
fibs :: [Integer] 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 Replace 0 by 1, if you want to exclude it from the sequence. I prefer to include it. Greets, Ertugrul. -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/