RProgN
Reverse Programmer Notation. Any expression written in reverse Polish notation should work.
TehFlaminTaco · Turing complete: unknown · ●●○ moderate
Tested with 6 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
RProgN, short for Reverse Programmer Notation, was written in Lua by TehFlaminTaco. The goal was that any expression in reverse Polish notation runs as it is, so 2 3 + 4 * gives 20. Words are separated by spaces. A number pushes itself, a known word runs, and a word the interpreter does not know is quietly skipped.
Read the story
When the program ends, the whole stack is printed from the top, one value per line. So a string on its own is a Hello World.
The machine
| Word | Does |
|---|---|
5, 2.5 | Push a number |
"text", 'text' | Push a string; spaces inside are kept |
+ - * / | Arithmetic; / always gives a float |
] [ \ | Duplicate, drop, swap |
p w | Print with a newline, write without |
true false | Booleans |
The full language has well over a hundred words for loops, functions, memory, Lua string patterns, and single character aliases for many of them. This implementation has the core above and stops on the rest.
Example
In the last one Hello is not a word RProgN knows, so it does nothing, and the stack is printed from the top.
In the last one Hello is not a word RProgN knows, so it does nothing, and the stack is printed from the top.
Patterns it teaches
- Stack machines: the stack is the program's only memory and its output.
- Concatenative: a program is words in a row, each acting on the stack the last one left.
Try this
- Print the average of 3, 4 and 8.
- Print three lines with
pand see where the final stack goes. - Hard: print
1 2 3on one line withw, leaving nothing on the stack.
Further
- The reference interpreter, in Lua, with sugar.txt for the short aliases
See also
Also in Golfing
Write your own in Run Convert a program from RProgN
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: rprogn.
Command line
shib run rprogn -e '2 3 + 4 *'shib manual rprognSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/rprogn.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language