Indirect
Three commands reach sixteen operations, by counting which one to run.
Quojil, 2014 · Turing complete: no · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Quojil made Indirect in 2014, after Minifuck. It has three commands, and none of them touches the data. + and - count a number up and down in the instruction bay, a single nibble. ! runs the operation that number names. So every operation is chosen indirectly, by first counting to it.
Read the story
The data is eight cells of one byte. There is an operation to move left but none to move right. The pointer wraps round the eight cells, so seven moves left make one move right.
The machine
| Op | Does | Op | Does |
|---|---|---|---|
| 0 | Move the pointer left | 8 | NAND the cell with the next |
| 1 | Add 1 to the cell | 9 | OR |
| 2 | Take 1 from the cell | 10 | NOR |
| 3 | Set the cell to 0 | 11 | XOR |
| 4 | Read a character into a cell of 0, else print the cell | 12 | NOT the cell |
| 5 | Open or close the file i/o | 13 | Sleep as many seconds as the cell says |
| 6 | Skip the next command if the cell is 0 | 14 | Stop |
| 7 | AND the cell with the next | 15 | Nothing |
While the file is open, op 4 writes to it and reads its last byte instead. This implementation keeps the file in memory for the run, and sleeping does not wait. Every other character is a comment.
Example
The cat sets the bay to 4.
The cat sets the bay to 4. The first ! finds the cell at 0 and reads, and the second finds it full and prints. It runs once, so only the first character comes back.
Thirty-three times op 1 makes 33, the code of !, and op 4 prints it.
Patterns it teaches
- Encoding tricks: sixteen operations behind one counter.
Further
See also
Indirect builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from Indirect
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: indirect.
Command line
shib run indirect -e '++++!!' --input 'A'shib manual indirectSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/indirect.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org