Forums > MaxMSP

iterate over list N times

October 8, 2013 | 12:30 pm

Hi,

Im sure im being really stupid here, but….

Ive got a list like so:

1 2 3 4 5 6

And I would like it to iterate 8 times and for it to start from the beginning again, so the resulting list would be:

1 2 3 4 5 6 1 2

Im wondering if there is any simple way to do this in max?


October 8, 2013 | 12:52 pm

this one’s relatively simple, but follows your request quite closely:
<code>

– Pasted Max Patch, click to expand. –

</code>

BUT I don’t like iterating when it can be avoided, so I thought it would be better to double the list, and chop off the excess.
<code>

– Pasted Max Patch, click to expand. –

</code>

but then I thought, hey, we know how long we want this list to be, and we know how long the incoming list is… so I think the best way of doing this is the following:
<code>

– Pasted Max Patch, click to expand. –

</code>


October 8, 2013 | 1:05 pm

This is so cool! The last solution you posted is the ultimate in efficiency, but its the first one that fits my description perfectly, because the list can change in size.

Thanks Wetterberg.


October 8, 2013 | 3:33 pm

also.. variable list length w/ variable n+

– Pasted Max Patch, click to expand. –

October 8, 2013 | 5:52 pm

I think this abstraction does what you want. (zl to the rescue)
<code>

– Pasted Max Patch, click to expand. –

</code>


Viewing 5 posts - 1 through 5 (of 5 total)