indexMap<T, U> function

Iterable<U> indexMap<T, U>(
  1. Iterable<T> iterable,
  2. U func(
    1. int index,
    2. T value
    )
)

A map function that calls the function with an enumeration as well as the value.

Implementation

Iterable<U> indexMap<T, U>(
    Iterable<T> iterable, U Function(int index, T value) func) sync* {
  int index = 0;
  for (final T value in iterable) {
    yield func(index, value);
    ++index;
  }
}