Course of Raku / Advanced / Subroutines / Signatures / Exercises

Sum all arguments

Problem

Write a subroutine total that accepts any number of arguments and returns their sum. Use a slurpy parameter and a reduction meta-operator.

Call it with the numbers 3, 5, and 7.

Example

The program prints:

15

Solution

See the solution

Course navigation

Signatures   |   Solution: Sum all arguments