Control Flow
ROX provides minimal but sufficient control flow constructs. All control flow is explicit.
Conditionals
if / else
Standard conditional logic. Boolean expressions must be explicit.
if (x > 10) {
print(['B','i','g','\n']);
} else if (x == 0) {
print(['Z','e','r','o','\n']);
} else {
print(['S','m','a','l','l','\n']);
}
Loops
repeat
ROX has a single loop construct: repeat. It iterates over a range of numbers.
Syntax: repeat var in range(start, end, step)
start: Inclusiveend: Exclusive (stop before this value)step: Increment amount
// Print 0 to 4
repeat i in range(0, 5, 1) {
// i is 0, 1, 2, 3, 4
}
To iterate backwards:
// Print 10 down to 1
repeat i in range(10, 0, -1) {
// i is 10, 9, ... 1
}