Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fib n | n == 0 = 0
| n == 1 = 1
| otherwise = fib (n-1) + fib (n-2)
fib'cps n k | n <= 1 = k n
| otherwise = fib'cps (n-1) $ \x ->
fib'cps (n-2) $ \y ->
k $ x + y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment