esolang

Urn

One instruction that moves bits from one place to another, and nothing else. Loops, tests and storage all come out of it.

Keymaker, 2013 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: 0110

The idea

Keymaker published Urn in 2013. Its only instruction takes bits from an in-source and passes each one on. On the way, a 1 can be caught by a block of code, and so can a 0. A caught bit runs its block and is gone. A bit that nothing catches goes on to the out-source.

Read the story

Registers are queues of bits. An instruction keeps going as long as its in-source has bits, so code that puts a bit back into the register it is reading makes a loop. Reading one bit from a register and acting on whether it was 1 or 0 makes a test. That is enough to run any Minsky machine, and the specification shows how.

The machine

( in-source : code for 1s : code for 0s : out-source )
PartCan be
in-sourceempty for the input, a string like 101, or a register named with the letters a to z
code for 1s, code for 0sInstructions, as many as you like, or none
out-sourceempty for the output, or a register

A string gives its bits again each time the instruction runs. The input is read to its end and must hold only 0 and 1. A line whose last character is ; is a comment.

Example

The cat lets every input bit fall through to the output.

The cat lets every input bit fall through to the output.

The first program puts 101 into a. Then each 1 from a sends 11 to b, and the 0 is not caught, so it goes to b as it is. b ends up as 11011.

Expected: 11011

The Minsky machine adds 2 to A, adds 2 to B, and then moves B into A one at a time. A register with value n holds n ones and a 0. The last sentence says A ends at 0 and B at 4, but the machine it describes ends with A at 4 and B at 0, and this implementation follows the machine. The two prints at the end show 11110 for A and 0 for B.

Expected: 111100

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from Urn

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run urn -e '(:::)' --input '0110'
shib manual urn

Source

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

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

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