Rotator
Brainfuck on a ring of five cells, where every command also takes one step right.
ChuckEsoteric08 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
ChuckEsoteric08 made Rotator from brainfuck by taking two things away. The tape is a ring of only 5 cells, and there is no <. In return the pointer moves one cell right after every command, whatever the command was.
Read the story
A step left is four steps right on a ring of five, so nothing is lost. Each brainfuck command becomes itself followed by >>. Those two add 4 steps to the 1 the command takes by itself, a full turn, so only the command's own move is left. < has no command of its own and becomes >> alone.
The machine
| Command | Does, before the step right |
|---|---|
> | Move one cell right |
+ - | Add or take 1; a cell never goes below 0 |
. , | Print or read a character |
[ ] | Loop while the cell is not 0 |
Cells have no upper bound. The end of input reads as 0.
| brainfuck | Rotator |
|---|---|
+ - . , [ ] | the same, then >> |
> | >>> |
< | >> |
Example
The cat is brainfuck's ,[.,], translated.
The cat is brainfuck's ,[.,], translated. It stops at the end of the input.
Brainfuck's ++++++++[>++++++++<-]>+. translated the same way prints A.
The longer program adds 1 to four cells 49 to 52 times, then walks them with [.>] and prints 1234.
Patterns it teaches
- Turing tarpit: five cells of unbounded size are enough for brainfuck.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from Rotator
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: rotator.
Command line
shib run rotator -e ',>>[>>.>>,>>]>>' --input 'hello'shib manual rotatorSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/rotator.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org