iterate<E> function

Iterable<E> iterate<E>(
  1. E value,
  2. E callback(
    1. E element
    )
)

Returns a lazy infinite list of repeated applications of the function to the initial value.

For example, the expression

iterate(0, (n) => n + 1);

results in the infinite iterable of all natural numbers:

[0, 1, 2, 3, 4, ...]

Implementation

Iterable<E> iterate<E>(E value, E Function(E element) callback) =>
    IterateIterable<E>(value, callback);