< Back to IRCAM Forum

For-loop vs. arithm-ser

Hello,

Since I almost never used forloop, I was wondering how this is different from arithm-ser.
Could someone please make an example of a situation where only forloop would work?

Thank you in advance,

Marco

Edited: ok, I see it can be used to define how many iterations to run.
I always used whileloop for that purpose…

Dear Marco,

Forloop is not arithmser. Forloop is an iterator for the Loop macro (or omloop patch).
It is used to control iteration steps. Usually we only use it as from 0 to n (integer). But we can also use it for other stuff.
And you are right it could be used as an arithm-ser. But it is not its purpose.
My question now, why do you need to see the difference ?

Best
K

Dear Karim,

thank you for the quick reply.
I tend sometimes to mix up what something “is” and what it “seems to do”,
that’s why sometimes I “need” to see something in order to understand it.

So I had another look at the online documentation
http://support.ircam.fr/docs/om/om6-manual/co/ForLoop.html
and at the tutorial 36
http://recherche.ircam.fr/equipes/repmus/OpenMusic/user-doc/DocFiles/Tutorial/tut036/Index.html
In this two cases looks like doing what arithm-ser does (ok: I get that arithm-ser is not an iterator,
so I’d eventually need to listloop it).

The other use for forloop I can think about is to define how many iterations to do, e.g. to avoid infinite loops by random number generations.
In this case, if I’m not wrong, it’s the forloop without connecting the output and with input from 0 to n-iterations (step 1).

Am I missing something?

Thanks again!

Marco

Exactly,

forloop mainly is used to stop ongoing iterations. You can even use it without connection
At each iteration it will stop till it arrives at end like in the patch i am attaching,
The loop will print 11 times “toto” in the listener and stops… useless thing but illustrates well the use of forloop

Best
K

forloop.omp (1.77 KB)

Thanks, very clear!

Best,

Marco