Self-modifying Brainfuck, also known as SMBF, is a variant of brainfuck by Simon Howard, which allows a program to modify its own source code. The program code is placed in the data array, and the data pointer starts at the byte immediately after the last instruction in the code.
||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 a character and store it in the cell at the pointer|
||Jump past the matching |
||Jump back to the matching |
All characters other than
><+-., are ignored if executed but may be accessed, modified, or printed as part of the source code on the tape.
Hello, World! and then blocks for user input:
This will print
1 only in the Python interpreter (otherwise nothing), because it dynamically creates code on the tape outside of the initial program code:
This is a quine. It will print it's own source code:
<[<]>[.>]Quines are easy!