We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Headass

From Esolang
Jump to navigation Jump to search

Headass is an esoteric programming language by TheJonyMyster.

Memory

Memory consists of 4 registers and an array

Register Description
r0 Current register
r1 Accumulator
r2 Stored register
r3 Comparison register

The array starts with a single null value.

Instructions

Before executing the program, add a null value to the start of the input.

Instruction List
Instruction Description
U Remove the first input, then set r0 to new first input. If input is empty, set r0 to 0.
R Set r0 to the first input.
N Set r0 to 1 if the input is empty, else set r0 to 0.
D Set r0 to r1, and set r1 to 0.
^ Add the value in r0 to r1.
+ Add 1 to r0.
- Subtract 1 from r0.
[ Set r2 to r0, and set r0 to 0.
] Add the value in r2 to r0.
{ Start loop.
} Jump to matching {.
( Set r3 to r0, and set r0 to 0.
< If r0 is less than r3, set r0 to r3, else set r0 to 0.
> If r0 is greater than r3, set r0 to r3, else set r0 to 0.
) If r0 is not equal to r3, jump to the next :. set r0 to r3.
: Jump to next ;.
; A nop.
P Print r0.
? Print debug info.
O Push r0 to the array.
E Replace all inputs with the array, and set the array to a single null value again, then jump to a code block given by r0 (where 0 is the start of the program). Clear registers 0-3. If r0 is negative or larger than the number of blocks, halt.
. Separate code blocks. If execution reaches a . or the end of the program, halt.

Examples

Cat

N{N()UP}

Truth machine

U(+){P}:(P

Hello World

D--------O(+E
.N++++++++^[]][]][D^]]P]---P+++++++PP+++P(D]++++PD]PU]]]-P):P+++P------P--------P(]+P

Bubble sort

NO(+)(+E:{UO():N(+)(+++E:};{N(+)(++E:UO}
.N
.U+O{U+O():N(+)(+++E:};{N(+)(++E:U+O}
.UOU[{{N(+)(]O(++++E:U(]>):(]OR[};RO}
.UOUO[{N(+)(+++++E:UO(]>):R[};{N(+)(+++E:UO}
.U():R-O{U-ON(+)(+++++E:};{UON(+)(++++++E:}
.N{N()UP}

Computational class

Headass is Turing complete, as it is able to interpret Bitwise Cyclic Tag, shown below. Expected input is each bit of a BCT program as a separate input, followed by -1 as a divider, finally followed by each bit of input data as a separate input. For example: (1,1,0,1,0,0,-1,1,0) would run the program 110100 with 10 as input data.

NO(+):UO(-):{N(+);(++++++++E:UO(-):};N(+)(++++++++E:{UON()}:(+E  // init
.U+OR[{(]):UOD+^};UO[{UON()}:(](-)(++E:()(+++E:(++++E            // read instruction and move instruction pointer
.UDO{UON()}:(+E                                                  // loop to first instruction
.UO{(-):UO};UPN(+)(++++++++E:{UON()}:(+E                         // print and delete first bit of memory
.U+OR[{(]):UOD+^};UO[{UON()}:(](-)(+++++E:()(++++++E:(+++++++E   // check arg of "1" command and move instruction pointer
.UDO{UON()}:(++++E                                               // loop to first instruction within "1" command subroutine
.UO{(-):UO};UO[{N()UO}:(](+)(O:;(+E                              // add 0 to end of memory
.UO{(-):UO};UO[{N()UO}:(](+)(+O:;(+E                             // add 1 to end of memory
.N.                                                              // halt

Headascii

Headascii is a slight derivative of Headass, focused on printing characters rather than numerical output. Though it is named after ascii, it can support other character encodings per interpreter. A string register is added, one instruction is changed, and two are added to accommodate.

Instruction Description
P Concatenate r0 as a character (by character code) to the string register.
! Print the contents of the string register.
@ Clear the contents of the string register.

Quine

Using Headascii, a proper quine is possible.

O(++++++++O(+++++++++O(++++++++++O(+++++++++++++O(+++O(O(++++O(O(++++++++O(+++++O(++++++++++++++O(+++++++++++++++++O(++O(++++++++++O(+++O(+O(++++O(+++++O(+++O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(O(+++++++O(++++++++++++O(O(++++++++++++++++O(+++++++++++O(+++++++++++++++O(+++O(O(O(O(O(O(++O(+O(+O(+O(+O(++O(+O(+O(+O(+O(++++++O(+++++++O(+++O(O(O(O(O(O(++O(+O(+O(+O(+O(++O(+O(+O(+++++++O(++++++++++++O(+++++++++++O(+++++++++O(++++++++++O(+++++++++++++O(+++O(O(++++O(O(O(++++++++O(+++++O(++++++++++++++O(+++O(++++O(O(O(O(O(O(++O(+O(+O(+O(+O(O(++O(+O(+O(O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(++O(+O(+O(+O(++O(+O(+O(O(++O(+O(+O(+O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(++O(+O(+O(+O(++O(+O(+O(+O(++O(+O(+O(O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(++O(+O(+O(+O(+O(++O(+O(+O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(++O(+O(+O(+O(+O(++O(+O(+O(O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(O(++O(+O(+O(+O(O(++O(+O(+O(+O(O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(++O(+O(+O(+O(++O(+O(+O(+O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(++O(+O(+O(+O(+O(++O(+O(+O(+O(+O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(++O(+O(+O(++O(+O(+O(+O(+O(+O(+O(+O(++++++O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(++O(+O(+O(+O(++O(+O(+O(+O(O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(++O(+O(+O(+O(+O(++O(+O(+O(O(++O(+O(+O(+O(+++++O(++++++O(+++O(++++O(O(O(O(O(++O(+O(+O(+O(++O(+O(+O(O(++O(+O(+O(+O(+O(+O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(++O(+O(+O(+O(O(O(++O(+O(+O(+O(+O(+++++O(++++++O(+++O(++++O(O(O(O(O(++O(+O(+O(+O(O(++O(+O(+O(+O(++O(+O(+O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(O(O(++O(+O(+O(+O(+O(++O(+O(+O(+O(O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(++O(+O(+O(+O(+O(+O(+O(++O(+O(+O(++++++O(+++++O(++++++O(+++O(++++O(O(O(O(O(++O(+O(+O(+O(+O(++O(+O(+O(+O(+O(+O(+O(++++++O(++++++O(+++++O(++++++O(+++O(++++O(O(O(O(O(O(++O(+O(+O(+O(+O(++O(+O(+O(+O(+O(++++++O(+++++O(++++++O(+++O(++++O(O(O(O(O(++O(+O(+O(++O(+O(+O(+O(+O(O(+++++++++++++++O(+++++++O(+++++++++++O(+++++++++O(++++++++++++++++++O(+E.{N(+)+E:UO[{(]):(+++++++++++++++++++++++++++++++++++++++++++PD+^};(+++++[]]]][]]]]-P(+++++[]]]][]]PD}.{N(+)++E:U()+++++[]]]]+[]]+:-()+++++[]]][]]+[]]]:-()+++++[]]][]]][]]+:-()+++++[]]]][]]:-()+++++[]]]][]]+:-()++++++[]]]+[]]]+:-()+++++[]]][]]]:-()+++++[]]]][]]]]:-()+++++[]][]]]]]]]-:-()+++++[]]][]]]+:-()+++++[]]]][]]+[]]]:-()++++[]]][]]+[]]]]]:-()+++++[]]]++[]]]]:-()++++[]]]+[]]][]]:-()+++++++[]]]][]]]+:-()+++++[]]]]]][]]-:-()++++[]]]][]]]]]]--:-()+++++[]]]][]]]]-:-()++++[]][]]]]+;P}.!

Because nobody wants to sift through character codes to verify a quine.

Hello World again

Programs in Headass can easily be converted to Headascii by adding ! (and sometimes @) instruction(s) where appropriate. Here is a proper Hello, World! which outputs on one line.

D--------O(+E
.N++++++++^[]][]][D^]]P]---P+++++++PP+++P(D]++++PD]PU]]]-P):P+++P------P--------P(]+P!

Implementation

There is an implementation that's hosted here which supports both standard Headass and Headascii, last updated October 5 2021.

here is a Headass interpreter