Course of Raku / Advanced / Subroutines / The Whatever star 🆕 / Exercises / Whatever with map
Solution: Whatever with map
Here is a possible solution to the task.
Code
my $triple = * * 3;
say (1..4).map($triple);🦋 You can find the source code in the file whatever-map.raku.
Output
(3 6 9 12)Comments
* * 3is a Whatever expression that becomes a one-argumentWhateverCode— a perfectly ordinary function value stored in$triple.Because it is just a function,
mapaccepts it like any block, applying it to each element of1..4to give(3 6 9 12).