Last active
January 11, 2020 10:38
-
-
Save isaacabraham/354d407e5613c39606edf8418c4931e9 to your computer and use it in GitHub Desktop.
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 x = | |
[| 1 .. 10 |] | |
|> Array.map(fun n -> async { | |
printfn "Starting %d" n | |
do! Async.Sleep 1000 | |
printfn "Done %d" n | |
return n * 1000 | |
}) | |
let x2 = Async.Parallel(x, 1) |> Async.RunSynchronously | |
let x3 = x |> Async.Sequential |> Async.RunSynchronously | |
(* both output: | |
Starting 1 | |
Starting 2 | |
Starting 3 | |
Starting 4 | |
Starting 5 | |
Starting 6 | |
Starting 7 | |
Starting 8 | |
Starting 9 | |
Starting 10 | |
Done 10 | |
Done 2 | |
Done 1 | |
Done 5 | |
Done 7 | |
Done 3 | |
Done 8 | |
Done 6 | |
Done 9 | |
Done 4 | |
*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment