Course of Raku / Functional, concurrent, reactive, and web programming / Functional programming / Reduction / Exercises / Sum a list

Solution: Sum a list

Here is a possible solution to the task.

Code

say [+] 10, 20, 30, 40;

🦋 You can find the source code in the file sum-list.raku.

Output

100

Comments

  1. [+] inserts + between every element of the list.

  2. The sum 10 + 20 + 30 + 40 is 100.

Course navigation

Sum a list   |   Product of a list