Rabbitsfoot
The program never loops. The input does, and every pair of numbers gets one run of the program.
IFcoltransG, 2022 · Turing complete: no · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
IFcoltransG made Rabbitsfoot in 2022 for the first Esolang Buffet event of the Unofficial Esolangs Discord. Its goal is to make writing a sorting algorithm as confusing as possible. It seems to have several kinds of value and of control flow, but underneath it is one stack of arrays that all have the same length w.
Read the story
The only loop is automatic. The program runs once for every list of w indices into the input, and the full stop at the end of each run writes the top array back into the input at those indices. With w = 2 that is every pair (i, j), the double loop of the simple sorting algorithm Stanley Fung published. The language is total, so every program ends.
The machine
| Command | Does |
|---|---|
[1 -1] | Push an array; its length sets w for the whole program |
, | Push the input numbers at the current indices |
+ * | Add or multiply two arrays element by element |
- | Replace each element by its sign, 1, 0 or -1 |
/ | Divide each element by w, rounding down |
~ | Pop w arrays as the rows of a square, transpose it, push the rows back |
. | Write the top array into the input at the current indices and end the run |
@ | Run line 1 again |
= | Run the first comment as code |
# or REM | Start a comment line |
When every list of indices has had its run, the input numbers are printed. Commands that the specification only names through its GitHub spec are left out, and so are % (shuffle) and <...>.
Example
The cat leaves the input alone, and zeros writes 0 over every number.
The cat leaves the input alone, and zeros writes 0 over every number.
The sort IFcoltransG sent to the judges is 97 bytes. Line 1 pushes the current pair swapped and then as it is. The first comment subtracts. The rest adds the pair, adds or takes away the distance between the two numbers, and halves, which leaves the larger one at i and the smaller one at j. The specification says [min max], but the rules give [max min], and that is the swap in Fung's algorithm. Run over every pair it sorts the list upwards.
Patterns it teaches
- Stack machines: with arrays on the stack instead of numbers.
- Hostile design: built so that one algorithm is all it can do.
Further
See also
Stack-based
Write your own in Run Convert a program from Rabbitsfoot
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: rabbitsfoot.
Command line
shib run rabbitsfoot -e ',.' --input '3 1 2'shib manual rabbitsfootSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/rabbitsfoot.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org