diff options
| author | Zachary Pierson <zacpiersonhehe@gmail.com> | 2017-04-06 17:50:23 -0500 |
|---|---|---|
| committer | Zachary Pierson <zacpiersonhehe@gmail.com> | 2017-04-06 17:50:23 -0500 |
| commit | c0019cc3050e0dab2716ed72c689710b99df610c (patch) | |
| tree | 23b6e7a0f2191af6e1329a521187db276e29d6f4 /code | |
| parent | 63345cd0d8a6d1c906026ed0f4a5f8622ee21e94 (diff) | |
| parent | c067a1f0ec3f8e089d2800e18da7f3db4f3c2a33 (diff) | |
Merge https://github.com/gingerBill/Odin
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); } |