Ferntape
One register and one queue that you turn like a loop of tape.
RainbowDash, 2024 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
RainbowDash made Ferntape on 19 March 2024. All memory is one queue of numbers and one register. New items go in at the front, and the only way to reach the rest is to pull the last item round to the front, as if the queue were a circular tape. A loop runs while the last item is not 0, so most programs start by pushing a 0 as a marker and then pull until they meet it again.
Read the story
The specification gives its own interpreter in JavaScript, and this implementation follows it. That interpreter prints with console.log, so every printed character or number ends its own line.
The machine
| Word | Does |
|---|---|
push | Put the register at the front, then set it to 0 |
pull | Move the last item to the front |
pop del | Take the last item into the register; drop it |
copy repl | Read item 0 into the register; write the register over the last item |
inc dec | Add or take 1, or the number that follows |
clr | Set the register to 0 |
deci asci | Print item 0 as a number or as a character |
inp | Put each character of a line of input at the front |
[ ] | Loop while the last item is not 0 |
Example
A cat program.
A cat program. The 0 it pushes first marks where the input ends, and each pull brings the next character to the front to be printed.
Hello world pushes the twelve character codes behind a 0 the same way.
The addition reads two digits, one a line. It prints each digit as it reads it and then the sum, which it counts up one at a time in a loop.
The specification also has Disan Count, which prints the 51 even numbers from 100 down to 0.
Patterns it teaches
- Turing tarpit: a queue and a register, turned by hand.
Further
See also
Queue-based
Write your own in Run Convert a program from Ferntape
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: ferntape.
Command line
shib run ferntape -e 'push inp pull [ pull asci ]' --input 'cat'shib manual ferntapeSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/ferntape.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org