ArrayChunk Op

ArrayChunk

Extracts x elements from an array


<p>Creates a new array with <code>Chunk Size</code> elements starting from <code>Start Index</code>, copies the values from the input array (shallow copy). If there are less elements in the array than <code>Chunk Size</code>, the size of the output array may be smaller. </p> <p>*Example 1: * </p> <ul> <li>Input Array: <code>1, 2, 3, 4, 5</code></li> <li>Start Index: <code>2</code></li> <li>Chunk Size: <code>3</code></li> <li>Output Array: <code>3, 4, 5</code></li> </ul> <p>*Example 2: * </p> <ul> <li>Input Array: <code>1, 2, 3, 4, 5</code></li> <li>Start Index: <code>3</code></li> <li>Chunk Size: <code>3</code></li> <li>Output Array: <code>4, 5</code></li> </ul> <p>ArrayChunk has a special mode – <code>Circular</code> – when set to <code>true</code>, elements from the beginning of the array will be included:</p> <p>Example 3: </p> <ul> <li>Input Array: <code>1, 2, 3</code></li> <li>Start Index: <code>1</code></li> <li>Chunk Size: <code>3</code></li> <li>Circular: <code>true</code></li> <li>Output Array: <code>2, 3, 1</code></li> </ul>


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


INPUT PORTS


Input Array (Array)

<p>The array to get a chunk out of</p>

Begin Index (Number:

<i>integer</i>

)

<p>The index where the chunk should begin</p>

Chunk Size (Number:

<i>integer</i>

)

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

Circular (Number:

<i>boolean</i>

)

<p>If true, values from the beginning will be taken when end reached</p>

OUTPUT PORTS


Output Array (Array)

<p>Included <code>Chunk Size</code> elements or less</p>

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