Dogless
One string with a marker in it. Each step rewrites the string, and what is left at the end is the output.
Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 13 known programs · Test method
Run it
The idea
Dogless is a spiritual successor to dupdog. A program is a string, and its first | is the marker. The character after the marker is the instruction. It is taken out of the string together with its parameters, and then it changes the string. An ordinary letter just moves to the left of the marker, so a plain string walks past the marker one character at a time.
Read the story
The run ends when there is no marker left, or when the marker reaches the end and is taken out. The string is then the output. There is no input; the program is its own data.
The machine
| Instruction | Does |
|---|---|
| any other character | Moves to the left of the marker |
\x | Puts x to the left of the marker, even a command |
| | Nothing |
$ab | Replaces the first a in the string with b |
"text" | Deletes up to the next quote |
? | Reverses the whole string |
^ | Swaps the parts before and after the marker |
~ | Appends the string as it was, ~ included |
! | Deletes everything, marker too |
<X >X | Runs X on the part before or after the marker only |
Inside < and > the part is the whole string for X, so its own first | is its marker. Two > in a row skip ahead past the next marker.
Example
In the second line ?
In the second line ? leaves abc|def and reverses it to fed|cba, and the letters walk past the marker. In the third $ab replaces the first a in the string with b. In the last one the first > hands de|fg to >?, which reverses only fg.
The specification shows the first step of 14 examples. Run on from there, 13 of them have one possible end, and all 13 are checked. The other is ~, which copies the program onto its own end, so abc|~def grows forever.
Patterns it teaches
- Self-modifying code: every instruction deletes itself and edits the rest.
- String rewriting: the whole state is one string.
Further
See also
Unknown year
Self-modifying
Write your own in Run Convert a program from Dogless
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: dogless.
Command line
shib run dogless -e 'abc|def'shib manual doglessSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/dogless.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org