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

Lambdas and closures

A lambda is a small, nameless function written inline — exactly the pointy blocks and Whatever expressions you have been passing to map and friends. A closure is a lambda (or any subroutine) that remembers variables from the place where it was created.

Closures are what make returned subroutines so useful: they carry a little piece of private state with them. This section looks at both ideas.

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. A counter
  2. A multiplier
  3. An accumulator

Course navigation

Solution: Filter with a block   |   Lambdas