Control Flow

RUDRA provides conditional branching and loops with a familiar shape.

Conditionals

fn main() {
    let n = 7;
    if n > 10 {
        print("big");
    } else if n > 5 {
        print("medium");
    } else {
        print("small");
    }
}

While loops

fn main() {
    let mut i = 0;
    let mut total = 0;
    while i < 5 {
        total = total + i;
        i = i + 1;
    }
    print(total);
}

This program prints 10.

For loops over a range

fn main() {
    for k in 0..3 {
        print(k);
    }
}

The range 0..3 yields 0, 1 and 2.

Operators

Arithmetic: + - * / %. Comparison: == != < > <= >=. Logical: && || !.