CompressedBF
Brainfuck with run lengths, and one character for every pair and every triple of commands.
Joe · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
CompressedBF writes brainfuck shorter in two ways. A digit right after a command repeats it, so +8 is eight +. Every other character is a key from a table of 576 entries. The 64 pairs of commands each have a key, and so do the 512 triples. The specification calls it a very poor compression, made for golfing.
Read the story
The keys follow Python's printable characters in their own order. The pairs take 0 to 9, a to z, A to Z, ! and ". The triples take the rest of the punctuation, then space, tab, line feed, carriage return, vertical tab and form feed, and after those the characters from ® up to ʑ.
The machine
| Key | Commands |
|---|---|
+8 | ++++++++ |
0 1 2 ... 9 | ++ +- +< ... -- |
O P | [< [> |
# $ % | +++ ++- ++< |
ĵ š Ė | <.> >-] <+. |
ʑ | ]]] |
The pairs and triples run through the commands in the order + - < > . , [ ]. A count is one digit, so twelve - after a . come out as x-99, which is .-, nine - and the pair --. The brainfuck under it has byte cells that wrap, a tape with no end either way, and , reads 0 at the end of the input.
Example
The first is the Hello World, 164 commands of brainfuck in 57 characters.
The first is the Hello World, 164 commands of brainfuck in 57 characters. The second is the cat ,[.,], written as K for ,[, B for ., and a bare ]. The second Hello World has a carriage return in it, which the specification writes as \r.
Patterns it teaches
- Code golf: brainfuck at about a third of its length.
- Encoding tricks: run lengths and a dictionary of pairs and triples.
Further
See also
CompressedBF builds on Brainfuck.
Binary
Golfing languages
Write your own in Run Convert a program from CompressedBF
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: compressedbf.
Command line
shib run compressedbf -e '>+8O+9šĵ+4O+7šĖ+7A#ƭ+6O+7šĒx-99z+6O+9šĖk+3x-5x-7ƭo+3O+8šĖ'shib manual compressedbfSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/compressedbf.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org