Course of Raku / Functional, concurrent, reactive, and web programming / Functional programming / Higher-order functions / Exercises / Filter with a block
Solution: Filter with a block
Here is a possible solution to the task.
Code
say (1..10).grep(* > 5).elems;🦋 You can find the source code in the file filter-block.raku.
Output
5Comments
greptakes the block* > 5and keeps the numbers for which it is true:6, 7, 8, 9, 10..elemscounts them, giving5.