Laziness Weirds Programming

So I thought about it tonight and figured out that in Haskell I can generate the Fibonacci sequence using the definition

let l = [1,1] ++ zipWith (+) l (tail l)

If you type this at ghci you can say "take 20 l" and get

[1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765]

Laziness weirds programming. Friend of Bart

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.
Syndicate content