Ypsilax
The rules are drawn in the same grid they rewrite, so a rule can rewrite another rule.
Chris Pressey, 2001 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Chris Pressey invented Ypsilax in 2001. A program is a grid of symbols, and so is its state. A rule is a picture inside the grid, two squares side by side under a pair of parentheses. Wherever the left square appears below the rule, it may be replaced by the right square.
Read the story
A rule only rewrites what lies below it. That gives the grid a hierarchy. Rules near the top can rewrite rules further down, which rewrite the data at the bottom. Which rule fires, and where, is picked at random, and the run ends when no rule matches anywhere.
The machine
| Part | Does |
|---|---|
( ) | Stands above a rule; the 2n cells between the parentheses make it n rows high |
| left square | What the rule finds, blanks included |
| right square | What it writes in its place |
Ypsilax has no input or output. This implementation prints the grid when the run ends.
Example
The rule turns an A into a B, one at a time, until no A is left below it.
The rule turns an A into a B, one at a time, until no A is left below it.
A rule two rows high swaps BA for AB where the row under it is blank. It stops when the row is sorted, whichever pairs it picks first.
The specification compiles a Turing machine into rules, one per transition and per symbol beside the head. Its 4-state busy beaver is 14 rules over a tape row and a row that holds the state under the head. Only one rule matches at each step, so it halts the same way every time. After 106 moves it stops in state C on a blank, with twelve 1s on the tape and the head ten cells left of where it started.
Patterns it teaches
- Nondeterminism: the rule and the place are picked at random.
- Self-modifying code: rules are cells of the grid like any other.
- Two-dimensional control flow: position in the grid decides which rule can reach which cells.
Further
See also
Nondeterministic
Self-modifying
Write your own in Run Convert a program from Ypsilax
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: ypsilax.
Command line
shib run ypsilax -e '( )
AB'shib manual ypsilaxSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/ypsilax.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org