Documentation for method
batch assembled from the following types:
multi method batch(Int )multi method batch(Int :!)
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.
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
$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
$elems elements. Accordingly,
.batch($batch) is shorthand for