Course of Raku / Functional, concurrent, reactive, and web programming / Concurrent programming / Hyper and race 🆕 / Exercises / A hyper map

Solution: A hyper map

Here is a possible solution to the task.

Code

say (1..5).hyper.map(* * 3);

🦋 You can find the source code in the file hyper-map.raku.

Output

(3 6 9 12 15)

Comments

  1. .hyper lets the map run across threads.

  2. Because .hyper preserves order, the result is the same as an ordinary map: (3 6 9 12 15).

Course navigation

A hyper map   |   A racing sum