In Supply§

See primary documentation in context for method batch

method batch(Supply:D: :$elems:$seconds --> Supply:D)

Creates a new supply that batches the values of the given supply by either the number of elements in the batch (using :elems) or a duration (using :seconds) or both. Any remaining values are emitted in a final batch when the supply is done.

Note: Since Rakudo version 2020.12, the :seconds parameter has a millisecond granularity: for example a 1 millisecond duration could be specified as :seconds(0.001). Before Rakudo version 2020.12, the :seconds parameter had a second granularity.

In List§

See primary documentation in context for method batch

multi method batch(Int:D $batch --> Seq)
multi method batch(Int:D :$elems --> Seq)

Returns a sequence of lists, wherein each list with the exception of the last one is guaranteed to comprise a number of elements equal to the batch size specified by $batch or $elems, respectively. If the invocant has a number of elements that is not an integer multiple of the batch size, the last list in the returned sequence will contain any remaining elements and thus have less than $batch or $elems elements. Accordingly, .batch($batch) is shorthand for .rotor($batch, :partial).

In Any§

See primary documentation in context for method batch

multi method batch(Int:D $batch)
multi method batch(Int:D :$elems!)

Coerces the invocant to a list by applying its .list method and uses List.batch on it.