method batch

Documentation for method batch assembled from the following types:

class List

From List

(List) method batch

Defined As:

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).

class Supply

From Supply

(Supply) 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 the maximum number of seconds (using the :seconds) or both. Any remaining values are emitted in a final batch when the supply is done.

class Any

From Any

(Any) method batch

Defined as:

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.