mapN<R> method

Iterable<R> mapN<R>(
  1. R f(
    1. List<T> element
    ), {
  2. required int n,
})

Behaves like the map function but iterates over n elements at a time.

Implementation

Iterable<R> mapN<R>(R Function(List<T> element) f, {required int n}) sync* {
  Iterable<T> ptr = this;
  while (ptr.isNotEmpty) {
    yield f(ptr.take(n).toList());
    ptr = ptr.skip(n);
  }
}