Guest User

Untitled

a guest
Oct 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. let rec factorial(n : int) (mem : bigint) =
  2. match n with
  3. | 0 | 1 -> printfn "%A" mem
  4. | _ -> factorial (n - 1) (mem * bigint(n))
  5.  
  6.  
  7. let BigFactorial(numero,mesaje)=
  8. Async.FromContinuations(fun (cont,error,cancelation) ->
  9. printfn "begin number: %s" mesaje
  10. factorial numero 1I |>ignore
  11. printfn "begin number: %s ." mesaje
  12. cont())
  13.  
  14. //this doesn't works in async way...I get the 30M result first and then run the 10M
  15. Async.RunSynchronously(async{
  16. printfn "Start!!..."
  17. do! BigFactorial(30000,"30M")
  18. do! BigFactorial(10000, "10M")
  19. printfn "End!!..."
  20. })
  21.  
  22.  
  23.  
  24. //this works nicely
  25. let task1 = async{
  26. printfn "begin"
  27. do! BigFactorial(30000,"30")
  28. printfn "end..."
  29. }
  30.  
  31. let task2 = async{
  32. printfn "begin"
  33. do! BigFactorial(10000,"10")
  34. printfn "end!!..."
  35. }
  36.  
  37.  
  38. Async.RunSynchronously(Async.Parallel[task1;task2])
Add Comment
Please, Sign In to add comment