Course of Raku / Advanced / Control flow / gather and take / Exercises

Squares

Problem

gather/take lets you filter and transform in the same step. Loop over 1..6, and take the square of a number only when the number itself is even. Print the resulting list.

Example

The program prints:

[4 16 36]

Solution

See the solution

Course navigation

Solution: Repeat each number   |   Solution: Squares