abstraction for repeating an operation

Roman Thilenius's icon

i need to make an abstraction which can help me to repeat a certain process, for example on numbers,
for a given amount.

as you can see, i dont even know the right term for it.

let me give you an example instead:

there is a processs, [+ 5] which is applied to numbers. now i want to route the output of the
number back into the input in order to repeat [+ 5] fpr 17 times.

you might say that is easy with [counter] and [gate] but i cant find a simple and effective solution.

even when i start involving [grab] and pvars i see buffer underruns :D

does anyone have something like this already?

max 4.x or jpg please!

-110

Jesse's icon

How about a for loop in javascript?

Chris Muir's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Counter and Uzi are pretty much made for this (do something N times.) Here's an example:

968.Iterate.png
png
Roman Thilenius's icon

aha, "iteration", right, i should have known that word.

thanks for your ideas.

js is not an option for max4 and might be bit slow for timecritical
applications. but "loop" rings a bell.

indeed counter and uzi seem straightforward, but if you try
to redo the above patcher to work with [+ ] as well as [zl sort] and
[spintf] you will understand my problem with this method. :)

jit.matrxi or table are also not wrong ideas, yet limited.

i might stick to counter as there seem to be no other way.

Chris Muir's icon

The above patch is using [+], but I have no idea how you would like to use [zl sort] or [sprintf]. Perhaps if you posted your patch, we could see where you're going wrong.

Tj Shredder's icon

I would use scripting and Chris' method with counter, but with an deferlowed iteration (not as fast as uzi, but works). Then do a "script replace" on the operator (+) object to exchange it on the fly with another operator...
You could even script complex formulas by exchanging the + object with an expr object...

Max Patch
Copy patch and select New From Clipboard in Max.

1002.Iteration.png
png