Trigger
No command characters at all. Any character is an instruction, and how often it repeats says which.
Keymaker, 2005 · Turing complete: with unbounded memory · ●●○ moderate · esolangs.org
Tested with 6 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Keymaker made Trigger in 2005, out of work on his language Udage. Every byte value names a trigger, one bit of memory, so there are 256 bits in all. The program is read as runs of the same character. One x flips trigger x. Three in a row print it. Four read a bit of input into it. Two followed by a different character are a conditional jump.
The machine
| Pattern | Does |
|---|---|
X | Flip trigger X |
XXX | Print X |
XXXX | Read the next input bit into trigger X, most significant bit first |
XXY | If trigger X is 1, jump to the nearest Y on either side and run on from there |
A run of five is a read and a flip. Spaces and newlines count like any other character, so prints a space. The program ends at its last character, or at XX with nothing after it. The jump search looks left and right one step at a time and skips the pattern itself. When both sides match at once the reference picks at random; this implementation takes the left one. The reference is int-e's trigger.c, from yiap.nfshost.com/esoteric/trigger.
With 256 bits it is a finite machine.
Example
In Hello World, the # keeps the two runs of l apart.
In Hello World, the # keeps the two runs of l apart. The second program sets J, so JJx jumps to the second x and skips ooo. The third flips the space instead, J stays 0, and ooo prints.
Patterns it teaches
- Encoding tricks: the length of a run is the opcode, and the character is the operand.
Further
- esolangs.org/wiki/Trigger
- The Trigger page, with the spec and the C interpreter
See also
Pattern-based
Write your own in Run Convert a program from Trigger
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: trigger.
Command line
shib run trigger -e 'fffB'shib manual triggerSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/trigger.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org