27 points cremno 3 days ago 12 comments
abstractspoon 2 days ago | parent
MaulingMonkey 1 hour ago | parent
const size_t n = 10;
for (size_t i = n; i --> 0;) {
std::cout << i << "\n";
}ranger_danger 1 hour ago | parent
VHDL's array/vector syntax actually works a similar way:
-- gives 0, 1, 2, 3:
for i in 0 to 3 loop
-- gives 3, 2, 1, 0:
for i in 3 downto 0 loop
-- Source - https://stackoverflow.com/a/7642026 -- Posted by Kerrek SB -- Retrieved 2026-10-29, License - CC BY-SA 3.0
hedgehog 1 hour ago | parent
omoikane 3 minutes ago | parent
https://github.com/thaliaarchi/bfcorpus/blob/main/ebosman/ma...
Be sure to check out other files in that directory for how the program is assembled.
(Erik Bosman's mandelbrot set is a personal favorite of mine, very useful for benchmarking brainfuck interpreters)
kenferry 53 minutes ago | parent
while (i --> 0) {
// use array[i]
}
easy to read (if not understand), and correct!stephencanon 51 minutes ago | parent
(Hi Ken!)
krackers 46 minutes ago | parent
https://stackoverflow.com/questions/1642028/what-is-the-oper...
viega 38 minutes ago | parent
while (i-- != 0) { ... }
It's more clear than the most idiomatic way, which is to drop the explicit comparison: while (i--) { ... }
All of it is better than the clunky old for-loop syntax.mtklein 1 minute ago | parent