Self-Recursive Brainfuck
Jump to navigation
Jump to search
Self-Recursive Brainfuck is a joke derivative of 8-bit Brainfuck (Brainfuck where every cell can have 256 values) by Larho#9031 with an extra # instruction that transforms cells into self-referencing programs. Since Self-Recursive Brainfuck does not modify existing commands at all, any program that can be run in Brainfuck can also be run in Self-Recursive Brainfuck.
Instructions
The table below are the instructions for when the pointer is not on a program cell.
| Instruction | Meaning |
|---|---|
| + | Increment the value at the pointer |
| - | Decrement the value at the pointer |
| < | Move the pointer to the right 1 space |
| > | Move the pointer to the left 1 space |
| [ | If the value at the current cell is 0, jump to the matching ] |
| ] | If the value at the current cell isn't 0, jump back to the matching [ |
| . | Print the current cell's value as an ASCII character |
| , | Accept one byte of input from the user and store the byte in the current cell |
| # | Transform the current cell on the pointer into a self-referencing program. Data on the cell is not preserved. |
The table below are the instructions for when the pointer is on a program cell.
| Instructions | Meaning |
|---|---|
| + | Does nothing |
| - | Does nothing |
| < | Move the pointer to the left 1 space |
| > | Move the pointer to the right 1 space |
| [ | Jump to the matching ] |
| ] | Does nothing |
| . | Print the program's source code |
| , | Take the user's input and add it to the program |
| # | Transform the current program cell into a normal cell again and sets the value in it to 0 |
Examples
Quine
#.
Hello, World!
-[------->+<]>-.-[->+++++<]>++.+++++++..+++.[->+++++<]>+.------------.---[->+++<]>.-[--->+<]>---.+++.------.--------.-[--->+<]>.
Cat
,+[-.,+]
Implementations
This is an implementation of Self-Recursive Brainfuck in Self-Recursive Brainfuck:
#,>----------[++++++++++<,---------->][-]<#
It takes input until you press the Enter key then executes the code.