BrainFlump
One cell, and a dump you can throw values onto but only take back at random.
Dylan Renwick · Turing complete: no · ●○○ easy
Tested with 3 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
BrainFlump shrinks brainfuck's tape to a single cell. To keep a value for later you push it onto the dump with :. Getting one back with ; takes a random value out of the dump, so a program that stores more than one value cannot know which it gets.
The machine
One cell holding any integer, starting at 0, and a dump. This implementation follows the Python 2 interpreter in Dylan Renwick's repository BrainFlump, which is what TIO runs.
| Command | Does |
|---|---|
+ - | Add or take 1, with no wrapping |
: | Push the cell onto the dump |
; | Take a random value out of the dump into the cell |
, | Read a byte into the cell |
. | Print the cell as a byte |
( ) | Loops, left out here |
The README says . prints the cell modulo 127; the source prints it as it is. The loops in the source test a random value from the dump rather than the cell, and find their partner by counting, so this implementation leaves them out and stops at one. The random pop is seeded by the program and its input.
Example
The second program counts to 65, keeps it on the dump, counts on to 68, and takes the 65 back.
The second program counts to 65, keeps it on the dump, counts on to 68, and takes the 65 back.
Patterns it teaches
- Nondeterminism: with two values on the dump,
;may return either.
Further
- The interpreter, in Python 2
See also
Also in Jokes
Write your own in Run Convert a program from BrainFlump
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: brainflump.
Command line
shib run brainflump -e ',.,.,.' --input 'abc'shib manual brainflumpSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/brainflump.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language