zip2<A, B> function

Iterable<(A, B)> zip2<A, B>(
  1. Iterable<A> a,
  2. Iterable<B> b
)

Creates an iterable of Product2<A, B> by pairing up equally positioned items from both iterables a and b. The returned iterable is truncated to the length of the shorter of the two iterables.

Implementation

Iterable<(A, B)> zip2<A, B>(Iterable<A> a, Iterable<B> b) sync* {
  final first = a.iterator;
  final second = b.iterator;
  while (first.moveNext() && second.moveNext()) {
    yield (first.current, second.current);
  }
}