Course of Raku / Advanced / Subroutines / Anonymous subroutines / Exercises
An anonymous square
Problem
An anonymous subroutine does not have to be stored first — you can
pass it straight to another routine. Using the sub form
(not a pointy block), pass an anonymous “square” subroutine directly to
map over the list 1, 2, 3, and print the
result.
Example
The program prints:
(1 4 9)