Course of Raku / Functional, concurrent, reactive, and web programming / Functional programming

Reduction

Reduction is the act of combining a whole list of values into a single value by applying an operator between them: summing a list, multiplying it, finding its maximum, or joining its strings.

Raku has two ways to do this — the reduce metaoperator [ ], which turns any infix operator into a list reducer, and the reduce routine, which does the same with a block. This section covers both.

Topics in this section

Practice

Complete the quizzes that cover the contents of this section.

Exercises

This section contains 3 exercises. Examine all the topics of this section before doing the coding practice.

  1. Sum a list
  2. Product of a list
  3. Join the strings

Course navigation

Solution: An accumulator   |   The reduce metaoperator