Subtractpocalypse
Counters and a list of changes to them. Going below zero is the only branch, and it restarts everything.
ais523, 2016 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
ais523 made Subtractpocalypse in 2016. Data lives in named counters, as in a Minsky machine. A program is a list of commands, and each command adds to some counters and subtracts from others, all at once. That is all. There is no jump.
Read the story
Control flow comes from failure. A command that would take a counter below zero does nothing at all, and the program starts again from the top, with the counters as they are. The program ends when the last command succeeds. Keymaker showed it is Turing complete by translating any Minsky machine into it: every pass through the program simulates one instruction, and the others are done and undone on the way.
The machine
x = 5 y = 6 z = 7
x + 3, y - 2;
z + 5;
The first line declares the counters and their starting values. Each command is a list of changes separated by commas and ended by a semicolon. At the end the first counter is printed as a number in base 256, one byte per digit, leaving out its leading digit.
Example
The specification's own programs are about control flow and print nothing.
The specification's own programs are about control flow and print nothing. Printing needs a first counter that spells bytes after a leading 1: 1, 72 and 105 in base 256 is 84073.
The example from the specification ends with x at 6, a single digit, so it prints nothing.
Ideas it shows
See also
Also in Turing tarpits
Write your own in Run Convert a program from Subtractpocalypse
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: subtractpocalypse.
Command line
shib run subtractpocalypse -e 'x = 3 y = 2 z = 3
x + 3, y - 2;
z + 5;'shib manual subtractpocalypseSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/subtractpocalypse.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org