zipWithIndex property

Iterable<$<T, int>> zipWithIndex

zip values with index

example


['a','b','c','d','e'].zipWithIndex // => [('a',0),('b',1),('c',2),('d',3),('e',4)]

Implementation

Iterable<$<T, int>> get zipWithIndex => fold<$<List<$<T, int>>, int>>(
    const $([], 0),
    (acc, elm) => $([...acc.$0, $(elm, acc.$1)], acc.$1 + 1)).$0;