Course of Raku / Functional, concurrent, reactive, and web programming / Concurrent programming / Hyper and race 🆕 / Exercises / Hyper with a filter

Solution: Hyper with a filter

Here is a possible solution to the task.

Code

say (1..10).hyper.grep(* > 5);

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

Output

(6 7 8 9 10)

Comments

  1. .hyper parallelises the grep while preserving order.

  2. Only the numbers greater than 5 are kept, giving (6 7 8 9 10).

Course navigation

Hyper with a filter   |   Reactive programming