pairwise method
An iterable over the successive overlapping pairs of this iterable.
For example:
final input = [1, 2, 3, 4];
print(input.pairwise()); // [(1, 2), (2, 3), (3, 4)]
Implementation
Iterable<(E, E)> pairwise() sync* {
final iterator = this.iterator;
if (!iterator.moveNext()) return;
var previous = iterator.current;
while (iterator.moveNext()) {
final current = iterator.current;
yield (previous, current);
previous = current;
}
}