Odin
Pastebin:
New Paste
Save and Share
// Paste your Odin code here! // Help is available at https://paste.odin-lang.org/about package main import "core:fmt" main :: proc() { program := "+ + * 😃 - /"; accumulator := 0; // Look at line 19 for token in program { switch token { case '+': accumulator += 1; case '-': accumulator -= 1; case '*': accumulator *= 2; case '/': accumulator /= 2; case '😃': accumulator *= accumulator; case: // Ignore everything else } } fmt.printf("The program \"%s\" calculates the value %d\n", program, accumulator); }
Odin
Pastebin:
New Paste
Copy
Create New Paste