Twoee
Thue with the chance taken out. The first rule that fits always wins, and the string is printed at the end.
Matthew Cooke and Thomas Burnip, 2018 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Matthew Cooke and Thomas Burnip made Twoee in 2018, "because Thue isn't bad enough". It keeps Thue's rules, find this and replace it with that, but drops the randomness. At each step the first rule in the order written whose left side is in the string fires, so the order of the rules sets their priority. When no rule fits, the string itself is the output. Rules can also read a line of input and print text after they fire.
Read the story
Every operator is three characters long. The starting string is set with ;;= instead of Thue's empty ::= line, and any line without an operator is a comment.
The machine
| Line | Means |
|---|---|
a::=b | Replace a with b |
a::=::: | Replace a with a line of input |
a::=~::Prompt | Print the prompt, then replace a with a line of input |
a::=b~~~c | Replace a with b, then print c |
;;=a | The starting string is a |
Each step replaces the leftmost match of the rule. The specification does not say how text ends. Its interpreter is in Python, so the printed text and the final string end with a line break, as Python's print gives them.
Example
The Hello World turns ab into Hellob, then into Hello World, and prints that.
The Hello World turns ab into Hellob, then into Hello World, and prints that. It has no exclamation mark, though the article's heading does. The second program is the specification's own example without its comment lines. The string acdfg becomes b, then the first line of input, e, the second line and the third, while the rules print as they fire.
Further
Ideas it shows
See also
String-rewriting paradigm
Write your own in Run Convert a program from Twoee
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: twoee.
Command line
shib run twoee -e 'a::=Hello
b::= World
;;=ab'shib manual twoeeSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/twoee.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org