zip4<T> function

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

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

Implementation

zip4<T>(Iterable<Iterable<T>> it,
    dynamic Function(T a, T b, T c, T d) zipFunction) {
  if (it.length != 4) {
    throw ArgumentError('Needs 4 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], copy[3]));
  }

  return result;
}