zipWith<B, C> method

Iterable<C> zipWith<B, C>(
  1. C combine(
    1. T t,
    2. B b
    ),
  2. Iterable<B> iterable
)

Join elements at the same index from two different Iterable into one Iterable containing the result of calling combine on each element pair.

If one input Iterable is shorter, excess elements of the longer Iterable are discarded.

Implementation

Iterable<C> zipWith<B, C>(
  C Function(T t, B b) combine,
  Iterable<B> iterable,
) sync* {
  var it = iterator;
  var otherIt = iterable.iterator;
  while (it.moveNext() && otherIt.moveNext()) {
    yield combine(it.current, otherIt.current);
  }
}