UglyBF
UglyBF is an esoteric language based on brainfuck with a 6 instructions set, exchanging the octuple operations of its inspiration by an inversion switch, while contributing to augmented compactness via a duplication operator.
Commands
\
inverts the effect of the following command, where as the *
duplicates the coming operation's effect.
The instructions are the following:
Command | Effect if not inverted | Effect if inverted |
---|---|---|
+
|
Increment the memory cell at the pointer. | Decrement the memory cell at the pointer. |
>
|
Move the pointer to the right. | Move the pointer to the left. |
.
|
Output the character associated with the current cell. | Input a character and store its code in the same. |
[
|
If the cell at the pointer equals zero, jump forward past the matching \[ .
|
If the cell at the pointer does not equal zero, jump back past the matching [ .
|
\
|
Invert the effect of the following command. Doubling operations (* ) are ignored and passed through.
|
Invert the effect of the following command. Doubling operations (* ) are ignored and passed through.
|
*
|
Double the effect of the following command. Can be chained for accumulation. |
+
, >
, [
and .
have the same effect as in Brainfuck.
By harnessing the potential of the \
instruction, the four brainfuck commands not explicitly assigned to a separate token in UglyBF may be activated:
UglyBF | brainfuck equivalent |
---|---|
\+
|
-
|
\>
|
<
|
\.
|
,
|
\[
|
]
|
The *
command doubles the effect of the following command, it's the only command that cannot be inverted.
If you want to duplicate the effect of an inverted command, you have to write \
before the first *
. The following examples should demonstate this concept:
*+ = ++ **+ = ++++ ****+ = ++++++++++++++++ \**+ = ----
Examples
Juxtaposing brainfuck and UglyBF
The brainfuck code
,++[->++<]>[<+>-]<.
becomes the UglyBF program
\.*+[\+>*+\>\[>[\>+>\+\[\>.
Printing “BF”
The UglyBF program
******+*+.>******+**+++.
writes the text “BF”.
Hello, world!
The following program prints “HELLO WORLD”:
******+***+.\*+\+.**+*++..*++.>*****+.\>***+.\***+.*++.\**+\*+.\***+.
Cat program
An infinitely repeating cat program is implemented in the following:
\..[\..\[
Interpreter
- Common Lisp implementation of the UglyBF programming language.