mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-31 02:12:04 +00:00
20 lines
402 B
Odin
20 lines
402 B
Odin
#import "fmt.odin";
|
|
#import "os.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;
|
|
default: // Ignore everything else
|
|
}
|
|
}
|
|
|
|
fmt.printf("The program \"%s\" calculates the value %d\n", program, accumulator);
|
|
}
|