Woodchuck
Brainfuck in a tree with no numbers in it. A value is how far a branch goes.
Rdococ, 2021 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Rdococ made Woodchuck in 2021. Its memory is a binary tree whose nodes hold nothing at all. You can walk down a branch, which grows it if it is missing, walk back up, or cut a node off with everything under it. The only test is whether the current node has both branches. The only arithmetic is an accumulator that counts up and empties itself when it prints.
Read the story
The specification shows that this is enough by translating brainfuck. Each brainfuck cell is a node, and the next cell hangs off its left branch. To its right hangs a zero node with one branch missing, and below that a chain of nodes with both branches. The length of the chain is the cell's value, so numbers are written in unary.
The machine
| Char | Does |
|---|---|
< > | Go down the left or right branch, growing it if missing |
^ | Go up to the parent |
% | Cut off the current node and everything under it, and go up |
[ ... ] | Loop while the current node has both branches |
+ | Add 1 to the accumulator |
. | Print the accumulator as a character and set it to 0 |
There is no input. Going up from the root is an error.
Example
The accumulator on its own prints anything; 33 is !.
The accumulator on its own prints anything; 33 is !.
The brainfuck program ++++++[>++++++++<-]>. put through the specification's table. Every + walks to the end of the chain and grows two leaves there, and every - cuts them back. It prints 48, the code of 0.
Brainfuck's usual Hello World, put through the same table, is 1,005 characters long and takes 77,315 steps to print Hello World!.
Patterns it teaches
- Turing tarpit: shown by translating brainfuck.
- Encoding tricks: numbers as the length of a chain of nodes.
Further
- esolangs.org/wiki/Woodchuck
- Brainfuck, the language it translates.
See also
Woodchuck builds on Brainfuck.
Brainfuck derivatives
Write your own in Run Convert a program from Woodchuck
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: woodchuck.
Command line
shib run woodchuck -e '<'shib manual woodchuckSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/woodchuck.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org