Created
October 14, 2018 21:39
-
-
Save dbrattli/702d4b2ffc66f36ac956254c201de67d to your computer and use it in GitHub Desktop.
Factorial Promise
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
let rec factorial (n : bigint) : Promise<bigint> = | |
let pr = Promise<bigint> () | |
pr.Resolve n | |
pr.Then (fun value -> | |
if value = (bigint 0) then | |
single (bigint 1) | |
else | |
factorial(n - (bigint 1)).Then (fun res -> single (n * res)) | |
) | |
let pr = factorial (bigint 10000) | |
pr.Then (fun value -> | |
printfn "Result = %A" value | |
) |> ignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment