BrainFunge2

From Esolang
Jump to navigation Jump to search

BrainFunge2 is an esoteric programming language created by NSQX made of two-character instructions, based on a few commands in Brainfuck, a few commands in Befunge, and NSQX's other thoughts.

Command Meaning
X+
Increase the memory value at the pointer by 1
X-
Decrease the memory value at the pointer by 1
P+
Increase the pointer by 1
P-
Decrease the pointer by 1
9>
Output the memory value at the pointer as decimal
<9
Input a decimal number to the memory value at the pointer
F>
Output the memory value at the pointer as hexadecimal
<F
Input a hexadecimal number to the memory value at the pointer
'>
Output the memory value at the pointer as ASCII
<'
Input a character as ASCII to the memory value at the pointer
''
Toggle string queue mode, for example, ''gnirts''
"X
Takes the last character out of the string queue and sets the memory value at the pointer to it's ASCII value
X"
Adds the memory value at the pointer as ASCII to the beginning of the string queue
_)
Jumps back to the beginning of the program
X(
Jumps past the matching )X if the memory value at the pointer is 0
)X
Jumps back to the matching X( if the memory value at the pointer is not 0
"(
Jumps past the matching )" if the string queue is empty
)"
Jumps back to the matching "( if the string queue is not empty
-)
Resets everything and jumps back to the beginning of the program
XE
Sets the error code to the memory value at the pointer
EX
Sets the memory value at the pointer to the error code
--
Exits with the error code before reaching the end of the program

Classic "Hello World!" program

In BrainFunge2, there are two ways a classic "Hello World" program can be written:

''
 !dlroW olleH''"("X'>)"
X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+
X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+'>X+X+X+X+X+X+X+
X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+'>X+X+X+X+X+X+X+'>'>X+X+X+'>X-X-X-X-
X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-
X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-'>X+X+X+X+
X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+
X+X+X+X+X+X+X+X+X+X+X+'>X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+'>X+X+X+
'>X-X-X-X-X-X-'>X-X-X-X-X-X-X-X-'>X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-
X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-
X-X-X-X-'>X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-X-'>

However, the shortest way is always preferred.