esolang

Headass

Four registers, a queue of numbers, and code blocks that hand an array to the next one as its input.

TheJonyMyster, 2021 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 6 known programs · Test method

Run it

Expected: 72 101 108 108 111 44 32 87 111 114 108 100 33

The idea

TheJonyMyster made Headass in 2021. A program is a row of code blocks split by dots. A block can only read its input, a queue of whole numbers, work in four registers and append numbers to an array. To go anywhere else it runs E, which makes the array the input of the block whose number is in r0. Reaching a dot or the end of the program halts.

Read the story

So a loop over data is a pipeline. The bubble sort is seven blocks that pass the list along until it is in order, and its Bitwise Cyclic Tag interpreter is nine.

The machine

CharDoes
U R NNext input into r0, current input into r0, r0 = 1 when no input is left
+ -Add or take 1 from r0
^ DAdd r0 to r1, move r1 to r0 and clear r1
[ ]Move r0 to r2, add r2 to r0
(Move r0 to r3, the comparison register
< >r0 becomes r3 if r0 is less, or greater, and 0 otherwise
) : ;If r0 differs from r3 jump past the next :; jump past the next ;
{ }Loop
P OPrint r0, append r0 to the array
E .Start block r0 with the array as input; end of a block

The input starts with a null before the numbers, so the first U fetches the first number. ) also sets r0 to r3, which makes X(+)then:else; an if 1 test.

Example

Hello World prints the codes of its letters, one a line.

Hello World prints the codes of its letters, one a line. Block 0 puts −8 in the array and starts block 1, which builds 8 in r1 and 32 in r2 and makes each code from them. U fetches the −8 to reach 87, the W.

Expected: 0
Expected: 5 6

The bubble sort from the specification. Block 0 copies the input. If one of the numbers is 0 it goes through block 2, which adds 1 to all of them, because < and > give 0 for false. Blocks 3 and 4 sort, block 5 takes the 1 off again and block 6 prints.

Expected: 1 3 5 7 9

The specification leaves open what "the input is empty" means for N. It means no input after the current one, which is the reading under which the cat, the sort and the BCT interpreter stop.

Patterns it teaches

  • Tag systems: the specification proves Headass Turing complete with a Bitwise Cyclic Tag interpreter. Run on 110100 with the data 10, it prints 1 0 1 1 0 and stops.
  • Turing completeness: blocks that call each other through an array are enough.

Further

Also in Turing tarpits

Write your own in Run Convert a program from Headass

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run headass -e 'N{N()UP}' --input '5 6'
shib manual headass

Source

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

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

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