4 ms·
I converted the example on the Gleam home page [0] to F#: let spawn_task i = async { let n = string i printfn $"Hello from
by munchler 2y ago
I converted the example on the Gleam home page [0] to F#:
let spawn_task i =
async {
let n = string i
printfn $"Hello from {n}"
}
// Run loads of threads, no problem
seq { 0..200_000 }
|> Seq.map spawn_task
|> Async.Parallel
|> Async.RunSynchronously
|> ignore
The two are pretty similar, but I would give F# the nod on this one example because it doesn't actually have to create a list of 200,000 elements, doesn't require an explicit "main" function, and requires fewer brackets/parens.
[0]: https://gleam.run/ https://gleam.run/
- jorams 2y agoThe creation of a list in the Gleam example is a choice, you could replace 'list' with 'iterator' and it would be lazy.