naz
Every instruction is a digit and a letter. One register, and it only goes up to 127.
sporeball, 2019 · Turing complete: no · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
sporeball made naz in 2019. A program is a string of pairs such as 9a or 1o, where the digit is the argument and the letter the instruction. All the work happens in one register that starts at 0 and may hold −127 to 127. Functions and variables are declared while the program runs, by switching the opcode.
Read the story
The output appears only when the program ends.
The machine
| Pair | Does |
|---|---|
na ns nm | Add, subtract, multiply by n |
nd np | Divide by n rounding down; keep the remainder |
no | Output n times, a digit for 0 to 9, a line feed for 10, the character for 32 to 126 |
nr | Read the n-th input character and remove it |
nf nv nn | Call function n; load variable n; negate variable n |
nx | Set the opcode to n |
nh | Halt |
In opcode 1, nf starts function n and every pair after it is added to the function until the line ends. In opcode 2, nv stores the register in variable n. In opcode 3, nv picks a variable and then nl, ne or ng calls function n if the register is less than, equal to or greater than it.
Example
The Hello, World! climbs to each character code by adding, multiplying and dividing.
The Hello, World! climbs to each character code by adding, multiplying and dividing.
A function declared in opcode 1 and called four times.
The alphabet stores 90 in variable 1, and two functions call each other while the register is less than it.
Patterns it teaches
- Counter machines: a Turing machine's tape sits in two variables as numbers.
- Turing completeness: with the 127 bound it is a finite automaton, and without it, universal.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from naz
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: naz.
Command line
shib run naz -e '9a7m2a1o
1x1f1a1o
1f1f1f1f'shib manual nazSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/naz.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org