aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-04-28 11:03:19 +0100
committerGinger Bill <bill@gingerbill.org>2017-04-28 11:03:19 +0100
commitc7575164ccba1b16d3ee3f160c6b4ebd2b337307 (patch)
treebb29728f69f3614e5aac2df8b0018602ed570c1c /code
parent99125dc743b3f8c073fa43368b7f43c385a96a0f (diff)
Revert to previous demo
Diffstat (limited to 'code')
-rw-r--r--code/demo.odin20
1 files changed, 13 insertions, 7 deletions
diff --git a/code/demo.odin b/code/demo.odin
index 7fdb7c0a6..323754a23 100644
--- a/code/demo.odin
+++ b/code/demo.odin
@@ -1,12 +1,18 @@
#import "fmt.odin";
main :: proc() {
- x: atomic int = 123;
- fmt.println(x);
- arr :[dynamic]any;
- append(arr, "123", 123, 3.14159265359878, true);
- for a in arr {
- fmt.println(a);
+ 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.print(arr, "\n");
+
+ fmt.printf("The program \"%s\" calculates the value %d\n", program, accumulator);
}