Skip to content

Instantly share code, notes, and snippets.

@ErikBjare
Created September 28, 2013 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErikBjare/6743437 to your computer and use it in GitHub Desktop.
Save ErikBjare/6743437 to your computer and use it in GitHub Desktop.
My first Haskell function, calculates the fibonacci sequence.
-- 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