Skip to main content

Mojo module

itertools

Provides iterator utilities for common iteration patterns.

This module includes functions for creating specialized iterators:

  • count() - Creates an infinite counter with customizable start and step values
  • product() - Computes the Cartesian product of two, three, or four iterables
  • repeat() - Repeats an element a specified number of times

These utilities enable functional-style iteration patterns and composable iterator operations.

Functions​

  • ​count: Constructs an iterator that starts at the value start with a stride of step.
  • ​product: Returns an iterator that yields tuples of the elements of the outer product of the iterables.
  • ​repeat: Constructs an iterator that repeats the given element a specified number of times.

Was this page helpful?