mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-03 11:42:28 +00:00
19 lines
380 B
Odin
19 lines
380 B
Odin
#import "fmt.odin";
|
|
|
|
main :: proc() {
|
|
immutable program := "+ + * - /";
|
|
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);
|
|
}
|