chunk
array →
chunk(
size: integer
) → array
Splits an array into consecutive, non-overlapping chunks of at most the specified size, preserving a final partial chunk. It resembles a count-based tumbling window but, unlike general sliding or hopping windows, has no separate step and always keeps the final partial chunk. It does not group items by inactivity or time. Returns null when the input cannot be evaluated.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
size | integer | Yes | The strictly positive number of items in each chunk. |
Argument evaluation
size: Evaluated once in the enclosing context.
Examples
{1, 2, 3} | chunk(2) → {{1, 2}, {3}}
Kind: Function
Scope: array/partitioning
Aliases: chunk