Using arrays to avoid Repeat


Here’s one of the basic building blocks for avoiding Repeat nodes when you want to loop over the elements of an array. The “trick” is to use an array like [0, 1, 2, 3, 0, 1, 2, 3] as the indices for Select in Array. That way, you get an array that repeats the selected elements over and over. So instead of looping N times over an array of 4 elements, you simply have to process an array of 4 x N elements (in this example, the number of repeats N is = 3).

The above is effectively the equivalent to doing this using a Repeat node:

PS To build an array like [0, 1, 2, 3, 0, 1, 2, 3], you use the Modulo node:

To be continued…