I don't think I'll ever understand the, for(i = n; i > 0; i--) {} camp. Even when semantically you're writing a countdown, it's surprising enough to be costly.
-
-
Replying to @generativist
What's the better way to do it? A normal for loop that counts up?
1 reply 0 retweets 1 like -
Replying to @roshanpateI
IMO, yes. If your language has a range construct, that's better. But when you're just using a loop to do something `n` times, I think ++ is better than -- because my brain just erases the whole thing and immediately sees "range".
1 reply 0 retweets 0 likes -
Replying to @generativist @roshanpateI
Prob depends what you’re doing but in computational sciences it’s hugely important to make code read like the equations it implements and they are always written for some series i = 1, 2, ..., n
1 reply 0 retweets 1 like
Yea, absolutely. TBH, that may be why I experience such dissonance when I see the decrementing loop. If it's not just "do n times" then I anticipate sequenced indexing.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.