diff options
Diffstat (limited to 'code')
| -rw-r--r-- | code/demo.odin | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/code/demo.odin b/code/demo.odin index af7f453c5..1aa76f03e 100644 --- a/code/demo.odin +++ b/code/demo.odin @@ -14,9 +14,18 @@ #import "utf16.odin"; main :: proc() { - if x := 0; x < 0 { - fmt.println(x); - } else { - fmt.println(x); + 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); } |