chunkBy method

Iter<Slice<T>> chunkBy(
  1. bool compare(
    1. T,
    2. T
    )
)

Returns an iterator over the slice producing non-overlapping runs of elements using the predicate to separate them. [1, 1, 1, 3, 3] => [[1, 1, 1], [3, 3]] for (a, b) => a == b The predicate is called for every pair of consecutive elements.

Implementation

Iter<Slice<T>> chunkBy(bool Function(T, T) compare) {
  return Iter(_chunkByHelper(compare).iterator);
}