Generators

Denys Duchier

module
x-oz://system/adt/Generators.ozf

This module provides very experimental support for generators. Generators can be used in the for loop with the from keywords. Be warned that this design could very well change in the future.

Exports

{Generator.concat [G1 ... Gn] ?G}
creates a new generator G which is the concatenation of generators G1 through Gn
{Generator.tails +L ?G}
creates a generator G that produces all non-empty tails of list L
{Generator.count +From +To +By ?G}
creates a generator G that produces all integers starting at From and ending at most at To by steps of By. Whether we count up or down depends on the sign of By
{Generator.member +L ?G}
creates a generator G that produces the elements of list L
{Generator.keys +M ?G}
creates a generator G that produces the keys of mapping M. The latter can be a record, an array, or a dictionary.
{Generator.items +M ?G}
creates a generator G that produces the values of mapping M. The latter can be a record, an array, or a dictionary.
{Generator.entries +M ?G}
creates a generator G that produces the entries of mapping M. The latter can be a record, an array, or a dictionary.