esolang

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

Expected: x

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

OpDoesOpDoes
0Move the pointer left8NAND the cell with the next
1Add 1 to the cell9OR
2Take 1 from the cell10NOR
3Set the cell to 011XOR
4Read a character into a cell of 0, else print the cell12NOT the cell
5Open or close the file i/o13Sleep as many seconds as the cell says
6Skip the next command if the cell is 014Stop
7AND the cell with the next15Nothing

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.

Expected: !

Patterns it teaches

Further

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 indirect

Source

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