Course of Raku / Advanced / More about built-in types / Sequences / Exercises / The last three

Solution: The last three

Here is a possible solution to the task.

Code

say (5, 10 ... 50).tail(3);

🦋 You can find the source code in the file last-three.raku.

Output

(40 45 50)

Comments

  1. The seeds 5, 10 set an arithmetic step of five, and the sequence runs up to its endpoint 50.

  2. tail(3) returns the last three values of the finite sequence — 40, 45, 50 — just as head would return the first few.

Course navigation

The last three   |   Enumerations 🆕