While versus Repeat

Just like in programming, Repeat can be considered a generalization of While (K&R: the for loop is a generalization of the while).

The difference between While with Counter and Repeat with Counter is that when you use While with Counter, the counter doesn’t necessarily control the number of loop iterations. Typically you would use some boolean condition (for example, number of polygons reduced by more than 50%) to control the number of loops, rather than an incremented counter. The counter is a convenience, there for you to use inside the while loop.

Here’s a rather artificial example of equivalent While and Repeat loops. The While loop uses a counter inside the loop, and also in the condition. Note that I had to subtract one for the While loop, because inside While with Counter, the counter is incremented after the loop is executed.

In this example, it would be simpler to just use the Max Repeats: