Intramodular Transaction
Every value is an infinite sequence of bits, and four operators are all there is to change one.
Hakerh400, 2019 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Hakerh400 made Intramodular Transaction in 2019. A program defines operators, and every operand and every result is an infinite sequence of bits. Four operators are built in. 0 and 1 put a bit in front of a sequence, . drops the first bit, and ? picks one of two sequences by the first bit of a third. Everything else is recursion.
Read the story
Sequences never end, so they are worked out lazily, only as far as the output needs them. The specification says Qpliu wrote a brainfuck interpreter in it, which makes it Turing complete.
The machine
A definition is a name, its arguments, = and a body in prefix notation, closed by ;. The first definition is the main operator, and it gets the input.
| Operator | Gives |
|---|---|
0 s 1 s | s with a 0 or a 1 in front |
. s | s without its first bit |
? a b c | b if a starts with 1, else c |
Input and output are finite sequences. The specification puts a 1 before each bit and zeros after the last one, so 10 goes in as 1110 followed by zeros. The output is read back the same way, and it ends at the first 0 in an even place. Both are written as the characters 0 and 1.
Example
The first two are the cat and its bit reverser.
The first two are the cat and its bit reverser. ..str skips one encoded bit, its marker and the bit itself. lastBit walks to the end, dropLastBit copies all but the last bit, and reverse puts the last bit first and goes on with the rest.
The last flips each bit but steps over the 1 in front of it. The specification's own inverter flips every bit of the sequence, the markers too. On any input that is not empty its result then starts with 0, which ends the output at once.
Patterns it teaches
- Turing completeness: shown by a brainfuck interpreter written in it.
See also
Declarative paradigm
Write your own in Run Convert a program from Intramodular Transaction
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: intramodular-transaction.
Command line
shib run intramodular-transaction -e 'main str = str;' --input '10011100'shib manual intramodular-transactionSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/intramodular-transaction.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org