Documentation for method batch assembled from the following pages:
Class: Any §
From Any
(Any) method batch §
Defined as:
multi method batch(Int )multi method batch(Int :!)
Coerces the invocant to a list by applying its .list method and uses List.batch on it.
Class: Supply §
From Supply
(Supply) method batch §
method batch(Supply: :, : --> Supply)
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.
Class: List §
From List
(List) method batch §
Defined As:
multi method batch(Int --> Seq)multi method batch(Int : --> 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).