Skip to content

Instantly share code, notes, and snippets.

@kaja47
Created June 30, 2011 13:32
Show Gist options
  • Save kaja47/1056244 to your computer and use it in GitHub Desktop.
Save kaja47/1056244 to your computer and use it in GitHub Desktop.
CPS Fibonnacci
def fib[A](n: Int, k: Int => A): A = {
if (n < 2) k(1)
else fib(n-1, (x: Int) =>
fib(n-2, (y: Int) =>
k(x+y)))
}
fib(10, println)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment