Skip to content

Instantly share code, notes, and snippets.

@jutememo
Created May 5, 2011 08:37
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 jutememo/956745 to your computer and use it in GitHub Desktop.
Save jutememo/956745 to your computer and use it in GitHub Desktop.
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