Loop with custom iterator

Just stumbled over following code-case and was wondering if there is straight-forward represenation in VL:

for (int gridY=0; gridY<height; gridY+=stepY){
    for (int gridX=0; gridX<width; gridX+=stepX){

The important part is the use of custom iterator, not only “i++”. My workaround atm is to calculate the iteration-count before the loop, but maybe there is a better solution.

not really, vl only does the basic 0…Count-1 index which should cover 95% of all cases. you have to calculate the correct count and index on your own. should be straight forward.
however an advanced loop is of course possible but not on top of the priority list…

you can program your own iterator by setting the count to something super high and use an accumulator for the index that you increment by the step size and break the loop once the value is greater than width/height…

In the meantime I patched this :)

In my case, I know the maximum iteration-amount. So this should work for my case. But maybe a “WHILE”-region would be a nice feature for the future.

yep that totally works.
the most efficient solution for this particular case should be this:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.