Noether
Reverse Polish notation, one character per command, and nothing printed until the very end.
Beta Decay · Turing complete: unknown · ●●○ moderate
Tested with 8 known programs · Hello World on Try It Online: identical except the line end · Test method
Run it
The idea
Beta Decay named Noether after the mathematician Emmy Noether and describes it as a more functional and more useful version of his earlier language Fourier. It is a stack language in reverse Polish notation. 7 2/P divides 7 by 2 and prints 3.5.
Read the story
Every character that is not a command is a variable. ~a stores the top of the stack in a, and writing a pushes it back. !i counts i up by one, which is how loops count.
Output is collected in a buffer and printed once, when the program ends. If anything goes wrong on the way, Python stops with an error and the buffer is never printed.
The machine
| Command | Does |
|---|---|
5, N5, 1.5 | Numbers; N is the minus sign |
"text" | A string |
+ - * / ^ M | Arithmetic, power and modulo; on strings join, delete, repeat, index, split |
= > < | Compare, push 1 or 0 |
~x, x, !x | Store, fetch, count up a variable |
P ? @ | Add the top to the output, add a newline, clear the output |
I | Read a line of input |
{c}{then}{else} | If |
(body) | Repeat until the top equals the value taken at the start |
The if is a small state machine, not a nested block. Braces do not nest, and an if whose then part is the last thing in the program fails at the end.
Example
The second is the Fibonacci program from the reference.
The second is the Fibonacci program from the reference. The loop takes 12 from the input as its exit value and runs until the counter !i reaches it. The third is its quine; 34B is the quote character.
Patterns it teaches
- Stack machines: everything goes through the stack, even the loop condition.
- Quine: a string stored in a variable and printed twice, with quotes made by
34B.
Try this
- Read a number and print its square.
- Print the input string in upper case.
- Hard: print the numbers 10 down to 1.
Further
- The reference interpreter, interpreter.py
See also
Also in Golfing
Write your own in Run Convert a program from Noether
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: noether.
Command line
shib run noether -e 'I2*P ' --input '21'shib manual noetherSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/noether.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language