mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-03 03:32:37 +00:00
19 lines
372 B
Odin
19 lines
372 B
Odin
import "fmt.odin";
|
|
|
|
proc main() {
|
|
let program = "+ + * - /";
|
|
var accumulator = 0;
|
|
|
|
for token in program {
|
|
match token {
|
|
case '+': accumulator += 1;
|
|
case '-': accumulator -= 1;
|
|
case '*': accumulator *= 2;
|
|
case '/': accumulator /= 2;
|
|
case: // Ignore everything else
|
|
}
|
|
}
|
|
|
|
fmt.printf("The program \"%s\" calculates the value %d\n", program, accumulator);
|
|
}
|