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

Quiz — Lambdas

What does the following program print?

my &f = -> $x { $x + $x };
say f(9);
09
118
081
099

The pointy block is a lambda that adds its argument to itself. Called with 9, it returns 9 + 9, which is 18.

Course navigation

Lambdas   |   Closures