Course of Raku / Advanced /
Control flow / gather and
take / Exercises
Repeat each number
Problem
Using gather and take, build a list in
which every number from 1 to 4 appears as many
times as its own value: 1 once, 2 twice,
3 three times, and 4 four times. Print the
resulting list.
Example
The program prints:
[1 2 2 3 3 3 4 4 4 4]