Skip to content

Instantly share code, notes, and snippets.

@yoshiki
Created December 22, 2015 06:43
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 yoshiki/638d2c7316dc73e61a70 to your computer and use it in GitHub Desktop.
Save yoshiki/638d2c7316dc73e61a70 to your computer and use it in GitHub Desktop.
fib :: Int -> [Integer]
fib 0 = error "arg >= 1"
fib 1 = [1]
fib 2 = fib 1 ++ [1]
fib n = xs ++ [x + y]
where xs = fib (n - 1)
(x:y:_) = reverse xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment