Course of Raku / Advanced / Subroutines / Nested subroutines / Exercises

An inner sum

Problem

Write a subroutine compute that defines a nested helper add, which returns the sum of its two arguments. Inside compute, return add(2, 3) + add(4, 5).

Print the result of calling compute.

Example

The program prints:

14

Solution

See the solution

Course navigation

Solution: Closing over the outer   |   Solution: An inner sum