Created
October 11, 2014 21:23
-
-
Save davidallsopp/84ee79e7d81404da421f to your computer and use it in GitHub Desktop.
A GHCi session showing the classic lazy recursive Fibonacci implementation in Haskell.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| λ> 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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shouldn't that be 1: 1: etc ? See also https://gist.github.com/davidallsopp/5cbedf56e1cbdc4903f5