Last active
August 29, 2015 14:10
-
-
Save TerrorJack/1fc8f0eb8a8a45f78f14 to your computer and use it in GitHub Desktop.
Memoization in haskell
This file contains 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
fib :: Int -> Integer | |
fib = head . makefib where | |
makefib 0 = [0] | |
makefib 1 = [1,0] | |
makefib n = (head nextfib + head (tail nextfib)):nextfib where nextfib = makefib $ n - 1 | |
main :: IO () | |
main = print $ fib 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment