esolang

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

Expected: Hello, World!

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

CommandDoes
5, N5, 1.5Numbers; N is the minus sign
"text"A string
+ - * / ^ MArithmetic, power and modulo; on strings join, delete, repeat, index, split
= > <Compare, push 1 or 0
~x, x, !xStore, fetch, count up a variable
P ? @Add the top to the output, add a newline, clear the output
IRead 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.
Expected: 1 1 2 3 5 8 13 21 34 55 89 144
Expected: "~a34BPaP34BPaP"~a34BPaP34BPaP

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

  1. Read a number and print its square.
  2. Print the input string in upper case.
  3. Hard: print the numbers 10 down to 1.

Further

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 noether

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/noether.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language