map3<T, U, V, W> function

Iterable<V> map3<T, U, V, W>(
  1. Iterable<T> ts,
  2. Iterable<U> us,
  3. Iterable<W> ws,
  4. V func(
    1. T t,
    2. U u,
    3. W w
    ),
)

A map function that takes in 3 iterables. The Iterables must be of equal length.

Implementation

Iterable<V> map3<T, U, V, W>(Iterable<T> ts, Iterable<U> us, Iterable<W> ws,
    V Function(T t, U u, W w) func) sync* {
  final Iterator<T> itt = ts.iterator;
  final Iterator<U> itu = us.iterator;
  final Iterator<W> itw = ws.iterator;
  while (itu.moveNext() && itt.moveNext() && itw.moveNext()) {
    yield func(itt.current, itu.current, itw.current);
  }
  if (itu.moveNext() || itt.moveNext() || itw.moveNext()) {
    throw ArgumentError("Iterables aren't of equal length.");
  }
}