Skip to content

Instantly share code, notes, and snippets.

@davidallsopp
Created October 11, 2014 21:23
Show Gist options
  • Select an option

  • Save davidallsopp/84ee79e7d81404da421f to your computer and use it in GitHub Desktop.

Select an option

Save davidallsopp/84ee79e7d81404da421f to your computer and use it in GitHub Desktop.
A GHCi session showing the classic lazy recursive Fibonacci implementation in Haskell.
λ> let fib = 0: 1: zipWith (+) fib (tail fib)
λ> take 10 fib
[0,1,1,2,3,5,8,13,21,34]
λ> fib !! 100
354224848179261915075
λ> fib !! 1000
434665576869374564356885276750406258025646605173717804024817290895365554179490518904038798400792551692959225930803226347
75209689623239873322471161642996440906533187938298969649928516003704476137795166849228875
@davidallsopp

Copy link
Copy Markdown
Author

Shouldn't that be 1: 1: etc ? See also https://gist.github.com/davidallsopp/5cbedf56e1cbdc4903f5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment