Course of Raku / Functional, concurrent, reactive, and web programming / Functional programming

Lazy and infinite sequences

A lazy list computes its elements only when they are asked for. This makes it possible to describe sequences that are conceptually infinite — all the natural numbers, all the powers of two, the whole Fibonacci sequence — and then take just the part you need.

Raku builds such sequences with the sequence operator .... This section shows how to write finite and infinite sequences and how to pull values from them safely.

Topics in this section

Practice

Complete the quizzes that cover the contents of this section.

Exercises

This section contains 3 exercises. Examine all the topics of this section before doing the coding practice.

  1. The first multiples of seven
  2. Powers of three
  3. The Tribonacci sequence

Course navigation

Solution: Gather with a condition   |   The sequence operator