esolang

Metatape

Two kinds of data, null and tape. Anything else has to be built from how tapes nest inside tapes.

HactarCE, 2017 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: Hi

The idea

HactarCE made Metatape in 2017. A pointer moves along a tape of null cells. It can enter a cell, which turns a null into a fresh tape of its own, and exit again. There are no numbers and no characters, only whether a cell is null and what the tapes inside it look like.

Read the story

Input and output are bits. o writes a 0 for a null cell and a 1 for any other cell, so a character takes eight of them, high bit first.

The machine

CharDoes
< >Move left or right
e xEnter the cell, or exit to the tape around this one
nSet the cell to null
o iWrite a bit; read a bit, and set the cell to null if it is 0
?Set the cell to null on a random 0
( \| )If the cell is null skip to \| or )
[ ]Loop back to [
@ name {...} !x !{name}Define and call a subroutine
f{...}Run, then put everything back except the current cell
hHalt

Brackets and parentheses pair up on their own, so [...(]) is a loop that ends when the cell is null. Every bit read after the end of the input is 0.

Example

ex> leaves a tape in the first cell and moves to the null cell beside it.

ex> leaves a tape in the first cell and moves to the null cell beside it. From there o writes a 0 and <o> writes a 1. These two subroutines spell H and i.

The cat reads each byte into eight nested cells, keeps a flag that a 1 bit clears, and stops on a byte that left the flag set, which is a null or the end of the input.

Expected: cat

The Hello world program comments that it prints Hello, world!, but its calls spell Hello world! without the comma, and that is what it prints.

Patterns it teaches

  • Turing tarpit: the specification says < > e x n ( ) [ ] alone keep it Turing complete.
  • Encoding tricks: a value is the shape of a nest of tapes.

Further

Multi-dimensional languages

Cell-based

Write your own in Run Convert a program from Metatape

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: metatape.

Command line

shib run metatape -e '[ex>eex<<<<<<<<[eexix>(n|])[<(])[>(eo(xx<n>e|x)])xn<(|])' --input 'Hi'
shib manual metatape

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/metatape.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org