aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorZachary Pierson <zacpiersonhehe@gmail.com>2017-04-06 17:50:23 -0500
committerZachary Pierson <zacpiersonhehe@gmail.com>2017-04-06 17:50:23 -0500
commitc0019cc3050e0dab2716ed72c689710b99df610c (patch)
tree23b6e7a0f2191af6e1329a521187db276e29d6f4 /code
parent63345cd0d8a6d1c906026ed0f4a5f8622ee21e94 (diff)
parentc067a1f0ec3f8e089d2800e18da7f3db4f3c2a33 (diff)
Merge https://github.com/gingerBill/Odin
Diffstat (limited to 'code')
-rw-r--r--code/demo.odin17
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);
}