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 a “double” function, then call it with 7.

Example

The program prints:

14

Solution

See the solution

Course navigation

Solution: Apply twice   |   Solution: Make a multiplier