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.

GenerateSampleSEt_vs_Repeat

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.

Array_accumulation

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

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

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

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:

WordPress.com Logo

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

Facebook photo

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

Connecting to %s