Created
June 30, 2011 13:32
-
-
Save kaja47/1056244 to your computer and use it in GitHub Desktop.
CPS Fibonnacci
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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