expandIndexed<R> method

Iterable<R> expandIndexed<R>(
  1. Iterable<R> expand(
    1. int index,
    2. T element
    )
)

Expands each element and index to a number of elements in a new iterable.

Implementation

Iterable<R> expandIndexed<R>(
    Iterable<R> Function(int index, T element) expand) sync* {
  var index = 0;
  for (var element in this) {
    yield* expand(index++, element);
  }
}