Created
June 1, 2019 17:01
-
-
Save vvviiimmm/77b3470e63ce9cd281898339f2e72aa6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
object Main extends App { | |
def fix[A](f: (=> A) => A): A = { | |
lazy val a: A = f(a) | |
a | |
} | |
val gac: (=> BigInt => BigInt) => BigInt => BigInt = | |
fac => n => if (n == 0) 1 else n * fac.apply(n - 1) | |
val facF = | |
fix[BigInt => BigInt](fac => n => if (n == 0) 1 else n * fac.apply(n - 1)) | |
val factorial = fix(gac) | |
println(factorial(1000)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment