esolang

Headsecks

Brainfuck where every character counts. Its code point modulo 8 says which command it is.

andkerosine, 2012 · Turing complete: yes · ●○○ easy · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: Hello World!

The idea

andkerosine designed Headsecks in May 2012. Each character of the source is read as its code point modulo 8, and that number picks one of brainfuck's eight commands. No number gives a negative remainder, so every string of characters is a program. The specification gives 16 ways to write the infinite loop +[] in three characters each.

Read the story

The order of the commands was chosen so that a space is +, a tab is - and a line feed is <. The digits 0 to 7 are the eight commands in order, and so are the eight trigrams ☰ to ☷.

The machine

Modulo 8DigitTrigramBrainfuckDoes
00☰+Add one to the cell
11☱-Take one from the cell
22☲<Move left
33☳>Move right
44☴.Print the cell
55☵,Read a character, 0 at the end of input
66☶[Jump past the matching ] if the cell is 0
77☷]Jump back to the matching [ if it is not

The specification's own interpreter is gone. This implementation follows the Python by None1 that the wiki links. Its tape is a million cells that wrap at 256.

Example

The Hello World in the trigrams dialect is the well known brainfuck one.

The Hello World in the trigrams dialect is the well known brainfuck one. The line break in its middle is a line feed, code point 10, so it is the < that moves back two cells.

The cat is EDFEDG, which is ,.[,.], since E, D, F and G are 69, 68, 70 and 71. It prints each character and stops after it prints a null character. Written in digits, 56457 is the cat ,[.,], which stops at the end of input.

Expected: abc

The specification also has "Konnichi wa" in a kana dialect. Read with the recommended order it prints twelve zero bytes and a 254. Read with the order <>-+.,[] it prints Konnichi wkc and a line feed, so it was written for another mapping.

Patterns it teaches

Further

Headsecks builds on Brainfuck.

Brainfuck equivalents

Brainfuck derivatives

Write your own in Run Convert a program from Headsecks

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run headsecks -e 'EDFEDG' --input 'catdog'
shib manual headsecks

Source

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

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

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