splitn method

Iter<Slice<T>> splitn(
  1. int n,
  2. bool pred(
    1. T
    )
)

Returns an iterator over subslices separated by elements that match pred, limited to returning at most n items. e.g. n == 1 will return the whole slice. The matched element is not contained in the subslices. The last element returned, if any, will contain the remainder of the slice.

Implementation

Iter<Slice<T>> splitn(int n, bool Function(T) pred) {
  if (n < 0) {
    panic("'n' cannot be negative");
  }
  return Iter(_splitnHelper(n, pred).iterator);
}