aboutsummaryrefslogtreecommitdiff
path: root/code/demo.odin
blob: 0db3e0b555f56beb9bbb15a76bd7ad61535e42ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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);
}