Created
September 28, 2013 17:03
-
-
Save funrep/6744145 to your computer and use it in GitHub Desktop.
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
-- defines the fibonacci function, takes an integer and returns the fibonacci number | |
fib :: Int -> Int | |
fib n = if n <= 2 then | |
n | |
else fib (n - 1) + fib (n - 2) | |
-- define a infinit list of all fibonacci numbers | |
fibs :: [Int] | |
fibs = map fib [1..] | |
-- prints the tenth number in the list of all fibonacci numbers | |
main = print (fibs !! 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment