Files
ziran/examples/loops.zi
T
waozi 10e854af6b Add native std facades, fix ASCII lowercase and move site examples
Portable standard facades for byte text, environment, timers, randomness,
mapped files, streams, worker pools, directory trees and threads; full ASCII
lowercase in std/unicode; examples move to examples/ with generated site
pages; Go output handles mixed-width slice bounds.
2026-11-12 19:15:45 -03:00

24 lines
518 B
Ziran

// Loops: while, ranges, collections, break, and continue.
main :: () {
index: s32 = 1;
while index <= 3 {
print("while %\n", index);
index += 1;
}
for step: 0..2 {
print("range %\n", step);
}
fruits := string.["apple", "banana", "cherry"];
for fruit, position: fruits {
print("% is at %\n", fruit, position);
}
for number: 0..9 {
if number % 2 == 0 { continue; }
if number > 7 { break; }
print("odd %\n", number);
}
}