zip3<T> function

dynamic zip3<T>(
  1. Iterable<Iterable<T>> it,
  2. dynamic zipFunction(
    1. T a,
    2. T b,
    3. T c
    )
)

Combine elements of three iterables into pairs and perform a function between them.

Implementation

zip3<T>(Iterable<Iterable<T>> it, dynamic Function(T a, T b, T c) zipFunction) {
  if (it.length != 3) {
    throw ArgumentError('Needs 3 iterables but found ${it.length}');
  }
  List result = [];

  for (var v in zipList(it)) {
    List<T> copy = List.from(v);
    result.add(zipFunction(copy[0], copy[1], copy[2]));
  }

  return result;
}