Course of Raku / Advanced / Subroutines / The Whatever star 🆕 / Exercises / An open-ended range
Solution: An open-ended range
Here is a possible solution to the task.
Code
say (2, 4 ... *).head(4);🦋 You can find the source code in the file open-range.raku.
Output
(2 4 6 8)Comments
The seeds
2, 4set an arithmetic step of two, and the bare*as the endpoint means the sequence never ends.head(4)pulls just the first four values,2, 4, 6, 8. The sequence is lazy, so the unbounded tail is never computed — the bare star here means “whatever, with no upper limit”.