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
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 8 | Digit | Trigram | Brainfuck | Does |
|---|---|---|---|---|
| 0 | 0 | ☰ | + | Add one to the cell |
| 1 | 1 | ☱ | - | Take one from the cell |
| 2 | 2 | ☲ | < | Move left |
| 3 | 3 | ☳ | > | Move right |
| 4 | 4 | ☴ | . | Print the cell |
| 5 | 5 | ☵ | , | Read a character, 0 at the end of input |
| 6 | 6 | ☶ | [ | Jump past the matching ] if the cell is 0 |
| 7 | 7 | ☷ | ] | 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.
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
- Every text runs: there is no syntax error, only programs.
- Turing tarpit: brainfuck under another alphabet.
Further
See also
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 'cat dog'