Skip to content

Instantly share code, notes, and snippets.

@AKST
Created September 22, 2013 09:14
Show Gist options
  • Save AKST/6658261 to your computer and use it in GitHub Desktop.
Save AKST/6658261 to your computer and use it in GitHub Desktop.
A tail recrusive implementation of the fibonacci squence
fib :: (Eq a, Num a, Num b) => a -> b
fib n = impl n 1 0
where
impl 0 _ b = b
impl n a b = impl (n - 1) (a + b) a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment