esolang

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

Expected: Hello world!

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.

KeyMeans
"_"The starting string
any otherA rule. Replace its first occurrence by the value

Example

The binary counter, ported from Thue, adds one to 11111111111.
Expected: Hello world!

The binary counter, ported from Thue, adds one to 11111111111. The underscores mark both ends, and 1++ is a carry moving left.

Expected: 100000000000

Patterns it teaches

Further

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 myth

Source

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