DoubleFuck
Brainfuck twice over. A second tape with its own pointer and its own eight commands.
Turing complete: with unbounded memory · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
DoubleFuck keeps all of brainfuck and adds a second tape. The first tape answers to brainfuck's own commands. The second answers to eight new ones that do the same things, so a program can keep one counter on one tape and its letters on the other. The specification calls it DBF and says it is Turing complete by a trivial reduction from brainfuck.
Read the story
The specification carries a C++ interpreter, and this implementation follows it. Each tape has cells 0 to 5000, as its range check allows, and a loop's body ends at its closing bracket, so the two kinds of bracket may nest but not cross.
The machine
| First tape | Second tape | Does |
|---|---|---|
> < | v ^ | Move the pointer right or left |
+ - | / \ | Add or take 1, wrapping at 256 |
. , | : ; | Print or read a character |
[ ] | { } | Loop while the cell is not 0 |
Reading skips spaces and line breaks, as C++'s cin >> does, and leaves the cell alone at the end of the input. # prints the first six cells of each tape. A pointer that leaves the tape prints BF RANGE ERROR or DBF RANGE ERROR and stops the run.
Example
The Hello, World!.
The Hello, World!. The first line prints Hello, and the second World!.
The loop on the first tape runs ten times. Each time it adds 7, 10, 4, 3 and 8 to five cells of the second tape and 11 to the next cell of the first. That gives 70, 100, 40, 30, 80 and 110, the neighbours of H, e, ,, the space, W and o. The first line alone stops after the space.
Both tapes at once. The first tape reads an a. The second tape holds a 1, and its loop runs once to put that 1 beside the a, which the first tape's loop then adds in. 97 and 1 print as b.
Patterns it teaches
- Turing tarpit: eight more commands that add no power, only room.
Further
See also
DoubleFuck builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from DoubleFuck
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: doublefuck.
Command line
shib run doublefuck -e 'v++++++++++[-///////v//////////v////v///v////////^^^^>+++++++++++<]//:v/:///////::///:v////:v//:'shib manual doublefuckSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/doublefuck.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org