4 ms·
One of the more common examples is if you need to iterate backwards. It's awkward because the [0,N) interval becomes (N,0]. for(i=N-1; i>=0; i--)
by ufo 6y ago
One of the more common examples is if you need to iterate backwards. It's awkward because the [0,N) interval becomes (N,0].
for(i=N-1; i>=0; i--)
- naniwaduni 6y agoNotably, this requires you to use a signed index type, which is absurd. The alternative is to use the so-called goes-to operator: for (i=N; i --> 0;). But this actually relies on the postincrement semantics, which is a huge wart.