Created
September 28, 2013 15:50
-
-
Save ErikBjare/6743437 to your computer and use it in GitHub Desktop.
My first Haskell function, calculates the fibonacci sequence.
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
-- Takes an empty list *l* and calculates a *n* numbers in the fibonacci sequence | |
fib l n | |
| l == [] = fib [1,1] n | |
| length(l) <= n = fib (sum(take 2 l) : l) n | |
| otherwise = l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment