Frank,
Thanks for the reply. After looking at your code, I did find that I was "limiting" my thinking in that I had to put the "inner" loops inside of the other loops, instead of going from the inner-most loop to the outer, as you do in your example.
One problem that I see with your implementation is that it assumes that all the "iterators" will divide evenly, but that can be changed.
Basically, what I am trying to do is to create a means of iterating over a set of variable ranges (for use in a fractal search algorithm). And, I need to be able to have as many as 12 (and possibly more) loops embedded. While yours is a workable solution, I am trying to avoid having to build a set of iterators for each dimension that I am trying to create. It would be nice to have a single "iterator" that can handle more than a single loop.
The specs for what I "need" are:
number of embedded loops to create), or a list of numbers (the same as the list from 2.).
data. These values need to be easily changed.
Takes a reset message to "reset to initial conditions".
Takes a bang message to iterate to the next set of values.
An incoming bang once all the iterators have completed, will do nothing.
Has either (I don't which is best) a single outlet which will output
a list of all the iteration values, or a separate outlet for each iterator variable.
Does this need to have another outlet to indicate that the loop has completed? (ie a bang on the right-most outlet of the iterator).
Thanks,
Mike
Frank Barknecht wrote:
Hallo, Michael McGonagle hat gesagt: // Michael McGonagle wrote:
I am looking for an object that will create any number of "embedded" iterators. The best analogy would be having a bunch of embedded "for" loops, like this:
for (i = i_init; i < i_limit; i += i_inc) for (j = j_init; j < j_limit; j += j_inc) doSomething();
I have created an abstraction that acts as a single loop, and I am using "until" to control the loops iterations. I would like to be able to not use "until" as this forces a restriction of making sure that all operations be performed within the same "time-interval" as all others. I would like to be able to send a single bang to the "top of the loop", and have it output the next set of iterators. For example
[iterator 0 10 1 100 1000 100]
banging on the iterator would produce the follow excerpt:
0 100 0 200 ...etc 0 1000 1 100 1 200 ...etc
Isn't this simply a combination of two counters with [select i_limit]?
I attached an example, that solves, how I understood the question...
ciao
#N canvas 218 217 450 300 10; #X obj 122 41 inlet; #X obj 110 230 outlet; #X obj 152 102 f $1; #X obj 188 102 + $3; #X obj 176 139 select $2; #X obj 237 171 f $1; #X obj 237 206 s $0-reset; #X obj 175 40 r $0-reset; #X obj 110 208 f; #X obj 122 70 t b b; #X obj 176 174 outlet; #X connect 0 0 9 0; #X connect 2 0 4 0; #X connect 2 0 8 1; #X connect 3 0 2 1; #X connect 4 0 5 0; #X connect 4 0 10 0; #X connect 4 1 3 0; #X connect 5 0 6 0; #X connect 7 0 2 1; #X connect 8 0 1 0; #X connect 9 0 8 0; #X connect 9 1 2 0;
#N canvas 631 235 450 300 10; #X obj 100 114 metro 250; #X floatatom 214 187 5 0 0 0 - - -; #X obj 100 88 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; #X obj 100 135 iter 100 1000 100; #X floatatom 100 189 5 0 0 0 - - -; #X obj 214 159 iter 0 10 1; #X connect 0 0 3 0; #X connect 2 0 0 0; #X connect 3 0 4 0; #X connect 3 1 5 0; #X connect 5 0 1 0;