Hollow
A stack of strings, and lines that split and join them. Every line says where to go if it worked and where to go if it did not.
Keymaker, 2012 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Keymaker designed Hollow in 2011 and published it in 2012. Its memory is an unbounded stack of strings, and its only tools are building a string, pushing it, finding it and cutting it in two. A line either succeeds or fails, and each outcome moves the line pointer a number of lines up or down. That is all the control flow there is, and it is enough to be Turing complete.
Read the story
The specification's own program is a Markov algorithm. Three pairs of lines each look for one pattern, cut the string where it occurs and glue it back with the replacement in between. When no pattern is left, the string is printed.
The machine
A line is {data}, an instruction and success|failure. In the data part, .0 reads a character, .1 pops the stack, and .6 .7 .8 .9 stand for . { } and a line feed. Reading past the input or popping an empty stack gives the empty string and fails the line.
| Instruction | Does |
|---|---|
| none | Push the data |
. | Drop the data |
+ | Push the data twice |
\ | Move the lowest string that contains the data to the top |
= | Cut the top string at the data, the part before ending on top |
: | Print the data |
The success and failure parts are a run of < or >, which moves that many lines, or ?, which ends the program. An empty part stays on the line. A pointer that leaves the program gets stuck there for ever, as the specification asks.
Example
The program turns a binary number into that many stars, here 73 of them.
The program turns a binary number into that many stars, here 73 of them.
Line 2 has no success part, so it repeats, adding one character to the string each time, until the input runs out and the line fails. The pairs that follow apply the rules *0 to 0**, 1 to 0* and 0 to nothing, each time starting again from the first. The run carries out 190 lines.
Patterns it teaches
- String rewriting: a Markov algorithm built from cut and join.
- Stack machines: every value is a string on one stack.
Further
See also
Stack-based
Write your own in Run Convert a program from Hollow
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: hollow.
Command line
shib run hollow -e '{hello, world.6.9}:?'shib manual hollowSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/hollow.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org