Trivial brainfuck substitution

From Esolang
Jump to navigation Jump to search

TrivialBrainfuckSubstitution is not a single programming language, but rather a large family of programming languages that are trivial substitutions of the Brainfuck language.

Syntax

We will pick TrivialBrainfuckSubstitution("a","b","c","d","e","f","g","h") as an example. To write a program in TrivialBrainfuckSubstitution("a","b","c","d","e","f","g","h"), first make a program in BF. Then, convert it to according to this table:

Brainfuck TrivialBrainfuckSubstitution("a","b","c","d","e","f","g","h") Description
> a Move the pointer to the right
< b Move the pointer to the left
+ c Increment the memory cell under the pointer
- d Decrement the memory cell under the pointer
. e Output the character signified by the cell at the pointer
, f Input a character and store it in the cell at the pointer
[ g Jump past the matching h if the cell under the pointer is 0
] h Jump back to the matching g

In addition it's common to replace short sequences of brainfuck instructions with substitutions. For example [-] may be replace by a single instruction or some form of run length encoding might be used.

Example Members of the TrivialBrainfuckSubstitution family

Language Trivial brainfuck Substitution
Ook! TrivialBrainfuckSubstitution("Ook. Ook?", "Ook? Ook.", "Ook. Ook.", "Ook! Ook!", "Ook! Ook.", "Ook. Ook!", "Ook! Ook?", "Ook? Ook!")
Alphuck TrivialBrainfuckSubstitution("a", "c", "e", "i", "j", "o", "p", "s")
brainfuck TrivialBrainfuckSubstitution(">", "<", "+", "-", ".", ",", "[", "]")
brainfuck TrivialBrainfuckSubstitution("f", "rqi", "qua", "rtf", "lv", "j", "btj", "zxg")
Binaryfuck TrivialBrainfuckSubstitution("010", "011", "000", "001", "100", "101", "110", "111")
Blub TrivialBrainfuckSubstitution("Blub. Blub?", "Blub? Blub.", "Blub. Blub.", "Blub! Blub!", "Blub! Blub.", "Blub. Blub!", "Blub! Blub?", "Blub? Blub!")
Brainfuck, but every + is replaced with the bee movie script TrivialBrainfuckSubstitution(">", "<", [Too long to be put in this page], "-", ".", ",", "[", "]")
Brainfuck² TrivialBrainfuckSubstitution("Ook!", "Alphuck", "Fuckfuck", "POGAACK", "Unibrain", "Wordfuck", "Brainfuck²", "ZZZ")
Colonoscopy TrivialBrainfuckSubstitution(";};", ";{;", ";;};", ";;{;", ";;;};", ";;;{;", "{{;", "}};")
DetailedFuck TrivialBrainfuckSubstitution("MOVE THE MEMORY POINTER ONE CELL TO THE RIGHT", "MOVE THE MEMORY POINTER ONE CELL TO THE LEFT", "INCREMENT THE CELL UNDER THE MEMORY POINTER BY ONE", "DECREMENT THE CELL UNDER THE MEMORY POINTER BY ONE", "REPLACE THE CELL UNDER THE MEMORY POINTER'S VALUE WITH THE ASCII CHARACTER CODE OF USER INPUT", "PRINT THE CELL UNDER THE MEMORY POINTER'S VALUE AS AN ASCII CHARACTER", "IF THE CELL UNDER THE MEMORY POINTER'S VALUE IS ZERO INSTEAD OF READING THE NEXT COMMAND IN THE PROGRAM JUMP TO THE CORRESPONDING COMMAND EQUIVALENT TO THE ] COMMAND IN BRAINFUCK", "IF THE CELL UNDER THE MEMORY POINTER'S VALUE IS NOT ZERO INSTEAD OF READING THE NEXT COMMAND IN THE PROGRAM JUMP TO THE CORRESPONDING COMMAND EQUIVALENT TO THE [ COMMAND IN BRAINFUCK")
Fluffle Puff TrivialBrainfuckSubstitution("b", "t", "bf", "pl", "!", "?", "*gasp*", "*pomf*")
fuckbeEs TrivialBrainfuckSubstitution("f", "u", "c", "k", "b", "e", "E", "s")
GERMAN TrivialBrainfuckSubstitution("LINKS", "RECHTS", "ADDITION", "SUBTRAKTION", "EINGABE", "AUSGABE", "SCHLEIFENANFANG", "SCHLEIFENENDE")
Human's mind have sex with someone TrivialBrainfuckSubstitution("Move the pointer to the right", "Move the pointer to the left", "Increment the memory cell under the pointer", "Decrement the memory cell under the pointer", "Output the character signified by the cell at the pointer", "Input the character signified by the cell at the pointer", "Jump past the matching right bracket if the cell under the pointer is 0", "Jump back to the matching left bracket if the cell under the pointer is 0")
K-on Fuck TrivialBrainfuckSubstitution("うんうんうん", "うんうんたん", "うんたんうん", "うんたんたん", "たんうんうん", "たんうんたん", "たんたんうん", "たんたんたん")
Morsefuck TrivialBrainfuckSubstitution(".--", "--.", "..-", "-..", "-.-", ".-.", "---", "...")
Omam TrivialBrainfuckSubstitution("hold your horses now", "sleep until the sun goes down", "through the woods we ran", "deep into the mountain sound", "don't listen to a word i say", "the screams all sound the same", "though the truth may vary", "this ship will carry")
PenisScript TrivialBrainfuckSubstitution("8=D", "8==D", "8===D", "8====D", "8=====D", "8======D", "8=======D", "8========D")
Pikalang TrivialBrainfuckSubstitution("pipi", "pichu", "pi", "ka", "pikachu", "pikapi", "pika", "chu")
ReverseFuck TrivialBrainfuckSubstitution("<", ">", "-", "+", ",", ".", "]", "[")
Revolution 9 TrivialBrainfuckSubstitution("It's alright", "turn me on, dead man", "Number 9", "if you become naked", "The Beatles", "Paul is dead", "Revolution 1", "Revolution 9")
ReverseFuck TrivialBrainfuckSubstitution("meeP", "Meep", "mEEp", "MeeP", "MEEP", "meep", "mEEP", "MEEp")
SCREAMCODE TrivialBrainfuckSubstitution("AAAH", "AAAAGH", "FUCK", "SHIT", "!!!!!!", "WHAT?!", "OW", "OWIE")
Ternary TrivialBrainfuckSubstitution("01", "00", "11", "10", "21", "20", "02", "12")
Triplet TrivialBrainfuckSubstitution("001", "100", "111", "000", "010", "101", "110", "011")
UwU TrivialBrainfuckSubstitution("OwO", "°w°", "UwU", "QwQ", "@w@", ">w<", "~w~", "¯w¯")
ZZZ TrivialBrainfuckSubstitution("zz", "-zz", "z", "-z", "zzz", "-zzz", "z+z", "z-z")

There are of course, infinitely many members not listed here.

Interpreter

Interpreters for these languages are also generally trivial to write using a regular expression and a lookup table to convert the language to something that can be executed directly. Two simple examples are below.

Ruby Perl
#!/usr/bin/env ruby
eval 'm=Hash.new(p=0);'+ARGF.read.gsub(/./,
     '>' => 'p+=1;',
     '<' => 'p-=1;',
     '+' => 'm[p]+=1;',
     '-' => 'm[p]-=1;',
     '.' => 'putc m[p];',
     ',' => 'm[p]=STDIN.getbyte if !STDIN.eof;',
     '[' => '(',
     ']' => ')while((m[p]&=255)!=0);')
#!/usr/bin/env perl
%c=qw( > $p++;
       < $p--;
       + $b[$p]++;
       - $b[$p]--;
       . print+chr$b[$p];
       , $b[$p]=ord(getc);
       [ $b[$p]&=255;while($b[$p]){
       ] $b[$p]&=255;} );
$/=$,;$_=<>;s/./$c{$&}/g;eval

External links

  • r-fxxk, a Ruby package that can generate interpreters for arbitrary TrivialBrainfuckSubstitution members.