Course of Raku / Functional, concurrent, reactive, and web programming / Concurrent programming / Hyper and race 🆕 / Parallel maps with hyper

Quiz — hyper

What does the following program print?

say (1..4).hyper.map(* ** 2);
0(16 9 4 1)
1(1 4 9 16)
030
0(1 2 3 4)

.hyper spreads the map across threads but keeps the results in their original order, so it behaves just like an ordinary map — squaring each element gives (1 4 9 16).

Course navigation

Parallel maps with hyper   |   Unordered parallelism with race