Woodchuck

From Esolang
Jump to navigation Jump to search

Woodchuck is a Treehugger derivative by User:Rdococ, and partially inspired by the Kolmogorov machine.

Introduction

Like Treehugger, Woodchuck is a brainfuck derivative that operates on a binary tree instead of a linear tape. Unlike Treehugger, the binary trees that Woodchuck programs operate on are finite, but can grow with no bounds, and unlabelled, meaning that nodes do not hold values. Programs must encode temporary data into the structure of the tree itself by strategically creating and destroying parts of the tree.

Instructions

Instruction Action
< Traverses down the left branch from the current node, creating a new node if none exists there.
> Traverses down the right branch, creating a new node if none exists.
^ Traverses back up to the parent node.
% Destroys the current node and all of its descendants, and traverses back up.
[...] Runs the code within the brackets while both the left and right branches exist.
+ Increments the accumulator.
. Outputs the ASCII character corresponding to the accumulator's value, and then resets the accumulator to 0.

Translation from BF

A rudimentary translation from non-wrapping, unbounded brainfuck to Woodchuck is as follows:

brainfuck Woodchuck
+ >>[>]>^<^[^]^
- >>[>]%<%^[^]^
< ^
> <
. >>[>+].^[^]^
[ >>[^^
] >>]^^

Implementation

A rough implementation of Woodchuck is available here.