Triplet

From Esolang
Jump to navigation Jump to search

Triplet is (yet another) joke fork of Brainfuck, with the instructions changed into binary triplets.

Commands

Brainfuck Triplet Description
> 001 Move the pointer to the right
< 100 Move the pointer to the left
+ 111 Increment the memory cell under the pointer
- 000 Decrement the memory cell under the pointer
. 010 Output the character signified by the cell at the pointer
, 101 Input a character and store it in the cell at the pointer
[ 110 Jump past the matching ] if the cell under the pointer is 0
] 011 Jump back to the matching [

Hello, world! program

Note that in most interpreters, the spaces are not necessary.

001 111 111 111 111 111 111 111 111 111 110 100 111 111 111 111 111 111 111 111 001 000 011 100
010 001 111 111 111 111 111 111 111 110 100 111 111 111 111 001 000 011 100 111 010 111 111 111
111 111 111 111 010 010 111 111 111 010 001 001 001 111 111 111 111 111 111 111 111 110 100 111
111 111 111 001 000 011 100 010 001 001 001 111 111 111 111 111 111 111 111 111 111 110 100 111
111 111 111 111 111 111 111 111 001 000 011 100 000 000 000 010 100 100 100 100 010 111 111 111
010 000 000 000 000 000 000 010 000 000 000 000 000 000 000 000 010 001 001 111 010

Triplet-to-brainfuck converter in Python

import re
def tripletToBrainfuck(code):
    cmds = {"001": ">", "100": "<", "111": "+", "000": "-", "010": ".", "101": ",", "110": "[", "011": "]"}
    return [cmds[s] for s in re.findall("...", re.sub("[^01]", "", code))]

Note

This page was forked from Ook!.