Runespells
Spells are cast from runes, and a rune is worth as many words as it holds.
TehZ · Turing complete: unknown · ●●● hard · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
TehZ made Runespells. Its functions are runes, lists of commands with names like Mizo, Lafi and Nahweh. Runes go on one stack, and the only thing the language can see about a rune is how many commands it holds. That count is the character Mizo prints, the size of the rune Mizi makes from a byte of input, and what Nahweh compares before it runs a rune.
Read the story
Zi adds the commands of one rune to the end of another, so a program grows its own runes to count. Each rune has up to six variables, Fa Rin Gora Jyiku Nahy Zeha, set in its header to the ids of other runes. The program starts with the Spell.
The machine
| Command | Does |
|---|---|
Fa ... Zeha | Push the rune the variable names |
Zi | Pop two; add the second's commands to the top one |
Ni | Pop a rune and remove its last command |
Yah | Pop a rune and run it |
Mizo Mizi | Print a rune's count as a character; read a byte as a rune of that many Ne |
Lafi Tazi | Duplicate; pop |
Giyah V | Pop a rune and let V name the rune whose id is its count |
Chizo Chixo Chiyo | Start the rune over; if the stack is empty; if it is not |
Nahweh | If the third rune's count equals the top's, pop two and run the second |
Ne Gorpdne | Do nothing; end the program |
The end of input reads as a rune with no commands.
Example
The truth machine.
The truth machine. It compares the input rune with rune 1, which holds one Ne, so it loops on the byte 1. The character 0 is 48 Ne, so it prints 0 and ends.
Reading ! makes a rune of 33 Ne. Lafi puts that same rune on the stack again, not a copy, so Zi joins the rune to itself. The rune left on the stack then holds 66, and 66 is B.
The counter grows rune 2 by one Ne each time round and prints its count, the characters 0, 1, 2 and on, until it reads a 0 byte.
Patterns it teaches
- Self-modifying code: runes count by growing their own code.
Further
See also
Also in Functional and concatenative
Write your own in Run Convert a program from Runespells
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: runespells.
Command line
shib run runespells -e 'Rune 1[]: Ne
Rune 2[1]: Fa Mizo Chizo
Spell [1, 2]: Fa Rin Mizi Lafi Mizo Nahweh Gorpdne' --input '0'shib manual runespellsSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/runespells.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org