Your job is to create a simple interpreter for a simple golfing language.
Input will be in the form of string separated by spaces.
You can replace space separation with what you want
Output the result (a number or a string) obtained after performing all operations. If there are more than one output join the together to give a single result (no separators). The variable's initial value is always zero. i.e: It start at
Language Syntax :
The language has following operators :
inc ---> add one to variable dec ---> remove one from variable mult ---> multiply variable by 2 half ---> divide the variable by 2 Pri ---> print the variable to console (or whatever your language has) exit ---> end the program (anything after this is ignored)
inc inc inc dec Pri exit ---> 2 dec inc mult inc inc Pri ---> 2 inc inc inc mult half Pri exit inc ---> 3 inc Pri inc Pri inc Pri exit half mult ---> 123 Pri exit ---> 0 inc half Pri exit ---> 0.5
This is code-golf so shortest code in bytes for each language will win.
- Input will always be valid . (string of operators separated with space)
- You can round down to nearest integer if you don't want decimal places.