Open ForNeVeR opened 9 years ago
Good proposal! Thanks!
I need to think how this will actually look after the transpilation...
@ForNeVeR [+]+
is rather strange way to clean a cell and set it to 1. Are you sure you didn't mean [-]+
?
They are completely equivalent in all of the modern BF dialects, so yes, I am sure. Optimizing BF compiler (yes there is a such thing) should simply replace [+]
and [-]
with setting the cell value to zero.
Also, both of these instructions will execute in equal time (and very slowly) if the cell initially already was set to zero. Maybe even -[+]
could be used as a common case optimization.
@ForNeVeR ok, thanks for the explanation
There is a brainfuck extension known as "procedural brainfuck". It adds two additional commands/concepts:
(
and)
will define a piece of code as a procedure coded with the number in the current memory cell.:
will call a procedure defined with a number in the current memory cell.It helps to create more functional and interesting programs solving real-world problems with ease.
For example, this simple code defines a procedure with number
1
and calls it: