← All examples

For no cheat

for no_cheat — "no cheat": every round's work really happens, so the compiler may not replace the loop with its answer (here n(n+1)/2) or drop rounds; SIMD and cores are…

for_no_cheat.zg
# `for no_cheat` — "no cheat" (owner, 2026-10-01): every round's work really happens, so the compiler may
# not replace the loop with its answer (here n(n+1)/2) or drop rounds; SIMD and cores are still
# allowed. The strongest modifier comes first: `for no_cheat seq`, `for no_cheat para`.
MAIN {
    let mut 'acc': int64 = 0;
    for no_cheat 'i': int64 from 1 to 1000 by 1 {
        change 'acc' = 'acc' plus 'i';
    }
    let mut 'more': int64 = 0;
    for no_cheat seq 'i': int64 from 1 to 10 by 1 {
        change 'more' = 'more' plus 'i';
    }
    std::print.useful.auto_newln['acc', " ", 'more'];
}
Output
500500 55