Course of Raku / Functional, concurrent, reactive, and web programming / Functional programming / Lazy and infinite sequences / Infinite sequences

Quiz — Lazy sequences

What does the following program print?

say (2, 4, 6 ... *)[5];
010
112
014
06

(2, 4, 6 ... *) is the infinite sequence of even numbers. Counting from index zero, element 5 is the sixth even number, 12. Only as many elements as needed are computed, thanks to laziness.

Course navigation

Infinite sequences   |   The first multiples of seven