interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tests / compiler / progs / ifchain.osc

24 lines · 552 bytes Raw Blame History
1// entry: classify grade
2// if / else if / else chains.
3fn classify(x: i32) -> u8 {
4 if x < -1000 {
5 return 0;
6 } else if x < 0 {
7 return 1;
8 } else if x == 0 {
9 return 2;
10 } else if x <= 1000 {
11 return 3;
12 } else {
13 return 4;
14 }
15}
16
17fn grade(score: u8, bonus: bool) -> u8 {
18 let mut s: u16 = score as u16;
19 if bonus { s = s + 10; }
20 let mut g: u8 = 0;
21 if s >= 90 { g = 4; } else if s >= 80 { g = 3; } else if s >= 70 { g = 2; } else { g = 1; }
22 if s > 255 { g = 9; }
23 return g;
24}