Re:direction
Four arrows and a diamond. Every arrow the pointer runs is remembered on a queue, and the queue is all the memory there is.
ais523, 2018 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 4 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
ais523 made Re:direction in 2018. A program is a grid of arrows. The pointer runs over it, and each arrow it passes turns it and is also written onto the tail of a queue. The diamond ♦ takes the oldest arrow off the head of the queue and turns the pointer that way, so arrows run once when they are passed and once more when they come round again.
Read the story
Input and output are the queue itself. A number n is written as n right arrows and a down arrow. The program starts with the input on the queue and its output is whatever is left on the queue at the end.
The machine
| Command | Does |
|---|---|
◄ ▲ ► ▼ | Turn that way and push the direction onto the tail of the queue |
♦ | Shift a direction off the head of the queue and turn that way |
| anything else | Nothing |
The grid wraps on all four sides and the pointer starts top left, going right. The program ends when the pointer comes straight back to the arrow it just ran, which happens to an arrow alone on its row or column pointing along it. A ♦ on an empty queue is an error exit. The input and output are characters, as with TIO's -A switch, and < ^ > v + may stand in for the five symbols.
Example
The first program pushes one ◄ and stops on it, so the queue still holds the input.
The first program pushes one ◄ and stops on it, so the queue still holds the input. The second pushes 65 rights and a down, then stops on the lone ◄ below, and the queue reads 65, A. In the third the diamond keeps shifting the rights of x and coming back to itself round its one-column row, until it shifts the down and falls to the ◄. Only y is left.
Further
See also
Queue-based
Two-dimensional languages
Write your own in Run Convert a program from Re:direction
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: re-direction.
Command line
shib run re-direction -e '◄' --input 'echo'shib manual re-directionSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/re-direction.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org