Created
November 2, 2011 18:59
-
-
Save bkyrlach/1334541 to your computer and use it in GitHub Desktop.
Fixed Point Combinator
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
//This is as close as I've come thus far, but it cheats. :( | |
object Combinator { | |
def main(args:Array[String]):Unit = { | |
lazy val y:((Int => Int) => (Int => Int)) => (Int => Int) = g => g(y(g))(_) | |
val error:(Int => Int) = n => throw new java.lang.Exception("OOPS") | |
val fp:((Int => Int) => (Int => Int)) = f => n => if (n == 0) 1 else n * f(n - 1) | |
println(y(fp)(10)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment