Course of Raku / Functional, concurrent, reactive, and web programming / Functional programming / Higher-order functions / Exercises
Make a multiplier
Problem
Write a subroutine multiplier that takes a number
$n and returns a subroutine which
multiplies its argument by $n. Use it to build two
functions — a “double” and a “triple” — then call each with
7.
Example
The program prints:
14
21