From 5595daf5a39306179bb924f0c778bbba284391ec Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Tue, 9 May 2017 10:01:50 +0100 Subject: Revert demo.odin --- code/demo.odin | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'code') diff --git a/code/demo.odin b/code/demo.odin index 660594bae..323754a23 100644 --- a/code/demo.odin +++ b/code/demo.odin @@ -1,3 +1,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); } -- cgit v1.2.3