esolang

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

Expected: h i

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

WordDoes
pushPut the register at the front, then set it to 0
pullMove the last item to the front
pop delTake the last item into the register; drop it
copy replRead item 0 into the register; write the register over the last item
inc decAdd or take 1, or the number that follows
clrSet the register to 0
deci asciPrint item 0 as a number or as a character
inpPut 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.

Expected: H e l l o w o r l d !

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.

Expected: 3 4 7

The specification also has Disan Count, which prints the 51 even numbers from 100 down to 0.

Patterns it teaches

Further

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 ferntape

Source

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