Liberation
Bits lie still. Only the dots between them can act, and every dot acts at the same time.
Hakerh400, 2020 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
Hakerh400 made Liberation in 2020. The main string holds passive bits and active dots. A rule describes a dot together with a few bits on either side of it, and says what the whole piece turns into. The input is the string with one dot put in front, and the run ends when no dot is left. The bits that remain are the output.
Read the story
Rules apply in batches. In each step every dot that matches a rule is marked at once, all the bits their patterns cover are removed, and each marked dot becomes its replacement. A bit between two dots can be part of both patterns, and then it is removed once. Two rules that could ever match the same dot are a syntax error, so a step never has to choose.
The machine
| Rule | Does |
|---|---|
0.1 - 0 | A dot between 0 and 1 takes both bits and becomes 0 |
#.0 - 00. | A dot at the start before a 0 |
11.# - 10 | A dot at the end after 11 |
. - / | Any dot vanishes; / is the empty replacement |
A replacement may hold any number of dots, and the new dots act from the next step on. A dot that no rule matches waits, but when dots are left and no rule matches any of them, that is a runtime error. Input and output are written as the characters 0 and 1.
Example
The cat removes its one dot.
The cat removes its one dot. The inverter walks its dot to the right, flipping one bit a step.
To remove the last bit, the dot first puts a 0 in front of itself as a marker. It then moves right one bit a step while at least two bits lie ahead, and when one bit is left it removes that bit and the marker. On 1011 the string goes .1011, 0.1011, 10.011, 100.11, 1010.1 and 101.
The bit reverser has 20 rules. On 1011 it takes 47 steps to leave 1101.
Patterns it teaches
- String rewriting: with every match in a step applied at once.
Further
See also
String-rewriting paradigm
Write your own in Run Convert a program from Liberation
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: liberation.
Command line
shib run liberation -e '. - /' --input '1011'shib manual liberationSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/liberation.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org