blob: 323754a23e0c625ae0ccd281e1533c388c25bc2c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#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;
default: // Ignore everything else
}
}
fmt.printf("The program \"%s\" calculates the value %d\n", program, accumulator);
}
|