Array node

Array Chunk

Split an array into sub-arrays of fixed size. The last chunk may be smaller if the array length is not evenly divisible. Reports the number of chunks and the remainder size.

Inputs

PortTypeDefault
ArrayThe list to slice into fixed-size groups. The output is an array of sub-arrays.any—
SizeHow many elements go into each group. Values below 1 are treated as 1; a size larger than the list simply gives one group holding everything.int4

Outputs

PortType
Resultany
Chunksint
Remainderint

How It Works

Array Chunk divides the array into groups of Size elements each. The output is a nested array where each element is a sub-array of Size elements. If the array length is not evenly divisible by Size, the last chunk contains the remaining elements.

Example: [1,2,3,4,5] with Size=2 → [[1,2], [3,4], [5]]

Chunks reports the total number of chunks. Remainder is the number of elements in the last (incomplete) chunk, or 0 if all chunks are full.

Use Cases

  • Frame grouping: Chunk a flat sensor stream into frames of N samples each.
  • Matrix construction: Chunk a flat array into rows for matrix-like processing.
  • Batch processing: Split a large dataset into smaller batches for parallel or staged processing.
  • DMX universe packing: Chunk 512-channel DMX data into fixture groups.

Tips

  • To recombine chunks back into a flat array, use Array Flatten.
  • Remainder = 0 means all chunks are evenly sized.
  • Size must be at least 1. Setting Size larger than the array length produces a single chunk containing the entire array.

Open Array Chunk in the interactive catalog →

Array Chunk is one of 381 nodes in Grafit Pro.

Free download. Every feature for 7 days, no card. Then €99.99 once — or keep playing your projects as a Player.

More Array nodes