Myth
Thue written as one JSON object, run by 137 bytes of JavaScript.
Plugnburn, 2013 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Plugnburn wrote Myth on July 30, 2013 for the 140byt.es contest, where every entry had to fit in 140 bytes of JavaScript. The reference implementation is 137 bytes long.
Read the story
A program is a JSON object. The value under the key "_" is the starting string, and every other key is a rule that replaces itself with its value. As in Thue, the string is rewritten until no rule applies, and what is left is the output. Since any Thue program can be written this way, Myth is Turing complete.
The machine
Each round walks the keys in order and applies the first one found in the string, to its first occurrence only. Then the round starts again from the first key. The order is JavaScript's own, so keys that are whole numbers, such as "10", come first. When no key is found, the string is printed as it is.
| Key | Means |
|---|---|
"_" | The starting string |
| any other | A rule. Replace its first occurrence by the value |
Example
The binary counter, ported from Thue, adds one to 11111111111.
The binary counter, ported from Thue, adds one to 11111111111. The underscores mark both ends, and 1++ is a carry moving left.
Patterns it teaches
- String rewriting: a set of replacements applied until none fits.
- Turing completeness: borrowed from Thue by translation.
Further
See also
Nondeterministic
String-rewriting paradigm
Write your own in Run Convert a program from Myth
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: myth.
Command line
shib run myth -e '{"_":"Hello world!"}'shib manual mythSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/myth.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org