ArrayChunk Op

ArrayChunk

Extracts x elements from an array


Creates a new array with Chunk Size elements starting from Start Index, copies the values from the input array (shallow copy).
If there are less elements in the array than Chunk Size, the size of the output array may be smaller.

*Example 1: *

  • Input Array: 1, 2, 3, 4, 5
  • Start Index: 2
  • Chunk Size: 3
  • Output Array: 3, 4, 5

*Example 2: *

  • Input Array: 1, 2, 3, 4, 5
  • Start Index: 3
  • Chunk Size: 3
  • Output Array: 4, 5

ArrayChunk has a special mode – Circular – when set to true, elements from the beginning of the array will be included:

Example 3:

  • Input Array: 1, 2, 3
  • Start Index: 1
  • Chunk Size: 3
  • Circular: true
  • Output Array: 2, 3, 1

Edit Documentation

Full Name
  • Ops.Array.ArrayChunk
Visibility
  • Core Op - Official cables op
License
  • MIT
Author


 

INPUT PORTS


Input Array (Array)

The array to get a chunk out of

Begin Index (Number:integer )

The index where the chunk should begin

Chunk Size (Number:integer )

How big the chunk should be, if there are not enough elements at the end of the Input Array the chunk will be smaller

Circular (Number:boolean )

If true, values from the beginning will be taken when end reached

OUTPUT PORTS


Output Array (Array)

Included Chunk Size elements or less

Array length (Number)

Patches using ArrayChunk

  • Examples
  • Public
  • My Patches

Changelog


bugfixdo not crash when setting floats as begin/size, round down to next intuser avatarstephan - 2023-03-29 09:44