Using Generate Sample Set to avoid the Repeat node

Hat tip to Oleg who posted this tip on the mailing list some time ago.

The basic ideas is that instead of looping over an array with a Repeat with Counter, you use Generate Sample Set to get a data set, and you do everything in a per-generated element context.


As an example, let’s revisit the problem of taking one array and creating a new array where each element is the sum of the elements before it.


The old way, with a Repeat with Counter node, looks like this:

Using Generate Sample Set, you can work with a data set and use that to access the array elements:

Generate Sample Set is set up to give an exact number of samples:

2 thoughts on “Using Generate Sample Set to avoid the Repeat node

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s