chunkedTransform<R> method

  1. @useResult
KtList<R> chunkedTransform<R>(
  1. int size,
  2. R transform(
    1. KtList<T>
    )
)

Splits this collection into several lists each not exceeding the given size and applies the given transform function to an each.

@return list of results of the transform applied to an each list.

Note that the list passed to the transform function is ephemeral and is valid only inside that function. You should not store it or allow it to escape in some way, unless you made a snapshot of it. The last list may have less elements than the given size.

@param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection.

Implementation

@useResult
KtList<R> chunkedTransform<R>(int size, R Function(KtList<T>) transform) {
  return windowedTransform(size, transform, step: size, partialWindows: true);
}