Ratsize
A program read from the bottom up, one queue, and a pointer that can only climb.
Zero player rodent · Turing complete: yes · ●●● hard · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Zero player rodent made Ratsize, a two-dimensional language with one queue of integers for memory. The pointer starts on the last character of the last line and climbs one line per command. It can never go down, left or right on its own. The only way sideways is a branch. Y looks at the front of the queue and steps one column left on 0 and one column right otherwise.
Read the story
So a program is a tree of paths drawn upward, and a loop needs ^ to mark a place and v to jump back to it.
The machine
| Command | Does |
|---|---|
~ | Enqueue the digit on the line above, and skip it |
} { | Enqueue a copy of the front; dequeue |
+ - | Add or take 1 from the front |
Y y | Step left if the front, or the rear, is 0, else right |
^ v | Mark this place; jump back to the mark |
! * | Print the front as a number or as a character |
= | Enqueue a byte of input, 0 at the end |
P | Print the whole queue |
_ | End the program |
Every other character does nothing; the specification draws its paths with |. This implementation follows the interpreter in the Try It Online link, which also drops blank lines and stops with an error when the pointer reads outside the grid.
Example
Read upward, this enqueues a byte of input, prints it and ends.
Read upward, this enqueues a byte of input, prints it and ends.
A branch. With input the front is 65 and the pointer steps right to *; without, it is 0 and the pointer steps left to !.
The truth machine. It counts 48 off the input in a loop of four tens and then eight ones, then branches on what is left. On 0 it prints 0 and ends. On 1 it climbs into a loop of ^ ! v and prints 1 forever. Any other digit runs into the _ at the top right and ends without output.
The program in the Try It Online link is 52 lines tall and prints Hello.
Patterns it teaches
- Two-dimensional control flow: with one direction only, every branch is a fork in the path.
Further
See also
Queue-based
Two-dimensional languages
Write your own in Run Convert a program from Ratsize
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: ratsize.
Command line
shib run ratsize -e ' v
!
^
+ _
Y
_ -
! |
Y
| v
| {
| }
| -
| -
- -
- -
- -
- -
- -
- -
- -
- -
{ {
} }
Y
-
^
+
+
+
+
+
{
}
0
~
=' --input '0'shib manual ratsizeSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/ratsize.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org