8
Every command is a digit, every argument sits in brackets, and the program never ends on its own.
AmNow, 2021 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
AmNow made 8 in 2021. A command is a digit, then a colon, then its arguments in square brackets, then another colon. Commands that give a value, like 3:[x]: for the value of x, go inside the brackets of other commands. So a test in a loop reads 6:[3:[inp]:],[==],[1]:.
Read the story
8 runs in an infinite loop. When it reaches the end of the program it starts again from the top, and only 0:: halts it. The specification writes its strings in curly quotes, and the if command is marked with a section sign.
The machine
| Command | Does |
|---|---|
1:[x]: | Print x and a line feed; 1;[x]; prints it alone |
2:[x]<[y]: | Set the variable x to y |
3:[x]: | The value of x |
4:[x]: | Read a line into x |
5:[c];(...): | Run the commands in brackets while c is true |
7:[c]§(...): | Run them once if c is true |
6:[x]’[+]’[1]: | Set x to x plus 1 |
6:[a],[<=],[b]: | The value of a <= b |
0:: | Halt |
The specification leaves the operators open. This implementation uses + - * / % == != < > <= >=, and comparisons give 1 or 0. Text that reads as a number counts as that number, so a line of input can be compared and counted. Straight quotes work as well as the curly ones.
Example
The cat reads a line, prints it and reads the next while the line is not empty, and a line read at the…
The cat reads a line, prints it and reads the next while the line is not empty, and a line read at the end of the input is empty. Without its 0:: it would start again and wait for more. The last doubles n while it is at most 100.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from 8
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: 8.
Command line
shib run 8 -e '1:[“Hello, World!”]:
0::'shib manual 8Source
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/8.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org