Rotary
Every program is drawn as rings of 34 instructions, and the specification was written to confuse.
InputUsername, 2014 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
InputUsername made Rotary in September 2014, to be confusing rather than usable. It takes brainfuck's tape and one-character instructions and drops the loops. A program is one or more circles of exactly 34 instructions, drawn in a fixed ring shape, and each circle runs once, clockwise. Loops come from jumping to a circle, which starts it over.
Read the story
The tape has separate input and output pointers. , and + work under one, . and the tests under the other, so a program keeps moving two pointers. The specification says its specification was written to be confusing, unreadable and possibly lacking important information. The truth machine and reverse program settle the open points.
The machine
| Char | Does |
|---|---|
> < | Move the input pointer |
/ \ | Move the output pointer |
+ - , | Add 1, subtract 1 or read a character, at the input pointer |
. # | Print the cell at the output pointer as a character or a number |
? * | Run the next instruction only if that cell is 0, or only if it is not |
$ ~ @ | Push that cell; pop into the input cell; move the top of the stack to the bottom |
v ^ x | Start the next circle, the previous one, or circle n popped from the stack |
s % r ! | Print the n cells after the output pointer; push n mod the cell; a random byte; nothing |
A circle runs from the first cell of its top row, along the top, down the right side, back along the bottom and up the left. The program ends at the last instruction of whichever circle it is in. Circles are separated by blank lines.
Example
The truth machine.
The truth machine. The first circle reads a character, prints it and copies it to the next cell, where 28 - and 20 more in the second circle bring a 0 down to 0 and a 1 down to 1. On 0, * skips the v and the second circle ends the program. On 1 the third circle prints the cell again and again, as its x pops a 3 and starts circle 3 over.
The reverse program pushes each character of a line until a , reads a line feed, which ten - in a row bring to 0. Then it pops and prints them all. At the end of the input , reads 0, so after the last line it reads on and never stops.
Patterns it teaches
- Hostile design: the only loop is a jump to a whole circle, and the specification hides how the circles run.
Further
See also
Rotary builds on Brainfuck.
Two-dimensional languages
Brainfuck derivatives
Write your own in Run Convert a program from Rotary
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: rotary.
Command line
shib run rotary -e ' !!!!!!
!!! !!!
! !
! !
! !
! !
! !
!!! !!!
!!!!!!'shib manual rotarySource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/rotary.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org