ƎↃИAЯT
One type, whole numbers from 0 up, and one operation, addition. Everything else is done by matching on x + 1.
Hakerh400, 2020 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Hakerh400 made ƎↃИAЯT in 2020. A program is a list of functions, and a function is a list of cases. There is no subtraction, but a case may name its argument as x + 1. It then takes any number of at least 1 and calls the rest x, so subtracting is a matter of peeling ones off two numbers at once.
Read the story
sub(x + 1, y + 1): sub(x, y)
sub(x + 1, 0): x + 1
sub(0, y): 0
Before anything runs, every function is checked. Each possible list of arguments must meet exactly one case. A missing case or two cases that both fit stop the program.
The machine
| Formal | Takes | Binds |
|---|---|---|
5 | the number 5 | nothing |
x | any number | x to it |
x + 2 | any number of at least 2 | x to it minus 2 |
A body is numbers, names and calls joined by +. Functions with a different number of arguments are different functions, so shl(x) and shl(x, y) live side by side. main gets the input as one big number, its bytes joined with the first byte highest, and its result is printed the same way.
Example
The specification adds two digits.
The specification adds two digits. shr(x, 8) halves eight times to get the first byte, the rest of x is the second, and taking 48 off their sum leaves the digit of the answer. It works while the sum is below 10.
The dec function, with a main around it, takes one off the input.
Patterns it teaches
- Turing completeness: addition and matching on
x + 1are enough.
Further
See also
Also in Functional and concatenative
Write your own in Run Convert a program from ƎↃИAЯT
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: a-t.
Command line
shib run a-t -e 'main(x):
sub(shr(x, 8) + sub(x, shl(shr(x, 8), 8)), 48)
sub(x + 1, y + 1): sub(x, y)
sub(x + 1, 0): x + 1
sub(0, y): 0
shl(x, y + 1): shl(shl(x, y))
shl(x, 0): x
shl(x): x + x
shr(x, y + 1): shr(shr(x, y))
shr(x, 0): x
shr(x + 2): shr(x) + 1
shr(1): 0
shr(0): 0' --input '35'shib manual a-tSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/a-t.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org