need a good language tbqh
let rec fib x = if x <= 2 then 1 else fib(x-1) + fib(x-2)
let fibs =
Async.Parallel [ for i in 0..40 -> async { return fib(i) } ]
|> Async.RunSynchronously
The above code sample shows the elements of the Parallel CPU Asyncs pattern:
(a) “async { … }” is used to specify a number of CPU tasks
(b) These are composed in parallel using the fork-join combinator Async.Parallel
In this case the composition is executed using Async.RunSynchronously, which starts an instance of the async and synchronously waits for the overall result.