The concept of using variables to generalize brainfuck programs is described here: https://esolangs.org/wiki/Brainfuck_algorithms
In brainfuck, a variable is simply a label that refers to a specific memory cell. To exand the variable, means to use the current location of the Data Pointer and calculate the necessary amount of ">" or "<" to move the Pointer to the that location. This makes brainfuck code easily re-locatable. The Python 3 program 'bfvx.py' replaces the variable with zero or more ">" or "<". The output is an unformatted brainfuck program.
Required format:
- variable declaration
- brainfuck program with variables
Guidelines:
- variable names must not include brainfuck commands "><+-,.[]"
- variable names may contain any number of characters; upper and lowercase letters, numerals and many special characters
- other characters may cause Python errors
- there should be no comments in the program
- number of variables used must be hard-coded in the program, something large
Program examples with output.
1.
= a 5 (variable declaration)
a (program)
>>>>> (output)
2.
= a 8
= B 3
a+B
>>>>>>>>+<<<<<
3.
= a 5
= BB 2
a-BB
>>>>>-<<<
4.
= a 5
= B1 3
a>>>+B1
>>>>>>>>+<<<<<
5.
= a 3
= temp_1 7
= z 0
a++++[temp_1++a-]z
>>>++++[>>>>++<<<<-]<<<
6.
= a 3
= z 0
az
error: 'az' not a declared variable, will not produce >>><<<
7.
= x" 10
x"
probably error
Comments