Treehugger

From Esolang
Jump to navigation Jump to search

Treehugger is a brainfuck derivative by User:Cluid Zhasulelm with one change. Instead of the memory layout being a single infinite tape, it is an infinite binary tree. Replacing the commands < and > are the three commands ^ (back) which goes up the tree, < which takes the left branch and > which takes the right branch. Here is a diagram of the memory layout (except it is infinite downwards, the picture only shows 4 layers):

Fulbt.png

You can embed brainfuck programs into this language by searching and replacing < with ^. On the other hand it would be extremely difficult to interpret treehugger programs in brainfuck.

Questions and some partial answers

How can the wider memory be taken advantage of in programming?

  • Temporary variables can be encoded in binary in Treehugger (><<>), where they are written in unary (>>>>>>) in brainfuck.
  • You have an infinite tree next to every cell, so multidimensional data might be easier to work with (e.g. 2D or 3D arrays, list structured data). This has yet to be proved by making programs that show it.

Example Programs

Swapping two cells using a third:

+++++++<+++
.^.
[->+^]<
[-^+<]^>
[-^<+^>]^<
.^.

Running this:

$ cat test.th | ./Treehugger | od -t x1
0000000 03 07 07 03 0a

Implementations

See Also