mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-02 03:02:37 +00:00
21 lines
377 B
Odin
21 lines
377 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);
|
|
}
|