To add to the excellent answers from @LightnessRacesinOrbit and @basilikum, here is a tip I find helpful when looking at an unusual for
loop like this: break it down to a more primitive form.
Any for
loop:
for( initialize; condition; advance ) {
// loop body here
}
can be translated to an equivalent while
loop:
initialize;
while( condition ) {
// loop body here
advance;
}
So the loop you found:
for ( i = 0, j = nvert-1; i < nvert; j = i++ ) {
// loop body here
}
could be written:
i = 0, j = nvert - 1;
while( i < nvert ) {
// loop body here
j = i++;
}
Now we can take that and break it down to even simpler steps.
As @basilikum noted, the first line:
i = 0, j = nvert - 1;
is the same as:
i = 0;
j = nvert - 1;
and the last line of the loop:
j = i++;
is the same as:
j = i;
i = i + 1;
So putting those back into the code we end up with:
i = 0;
j = nvert - 1;
while( i < nvert ) {
// loop body here
j = i;
i = i + 1;
}
That's more verbose than the original for
loop, but it may be easier to think about if the original loop is confusing.