esolang

V (FMota)

No tape and no cells: an endless binary tree in which every node is the sum of the two below it.

Francisco Mota, 2007 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 3 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: cat

The idea

Francisco Mota made V around 2007. It is named after the pair of instructions \/. Its memory is a sum-tree, a binary tree that goes on forever both down and up, where the value of every node is the sum of its two subtrees. An operator walks the tree. It cannot set a value directly, since that would break the sums. Instead it moves 1 from the left subtree to the right, which leaves the node itself unchanged.

The machine

Everything starts at 0.

CommandDoes
\Move into the right subtree
/Go up to the parent. Coming up from a right subtree, first mirror the parent's whole tree, swapping every left and right
>Take 1 from the left subtree and give 1 to the right one
[ ]Loop while the node is not 0, as in brainfuck
.Print the node as a character
,Read a character into the node; the difference goes down the left subtrees, or the node becomes 0 at the end of the input

Taking 1 from a tree takes it from its right subtree, and so on all the way down; giving 1 gives it to the left subtree all the way down. Every other character is a comment.

The mirror is the trick that makes it work. \ goes right, and /\/ comes back up without leaving anything mirrored, so the right edge of the tree acts like a brainfuck tape:

BrainfuckV
> <\ /\/
+ -> \/>\/
[ ]\[/\/ \]/\/
. ,\./\/ \,/\/

In -, the mirror turns the tree around so that > moves the 1 the other way, and the second \/ turns it back.

Example

Brainfuck's cat, ,[.,], translated one command at a time.

Brainfuck's cat, ,[.,], translated one command at a time.

Expected: 123

Six times eight is 48, the character 0. The rest prints 1, 2 and 3.

Patterns it teaches

  • Turing tarpit: seven instructions, and a brainfuck tape has to be pieced together from a tree.
  • Turing completeness: the table above turns any brainfuck program into V.
  • Encoding tricks: a cell is not stored anywhere. It is the value of a node, which is a sum of an endless tree below it.

Try this

  1. Print A with as few instructions as you can find.
  2. Translate a brainfuck hello world.
  3. Hard: print the input backwards.

Further

V (FMota) builds on Brainfuck.

Brainfuck derivatives

Write your own in Run Convert a program from V (FMota)

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: v-fmota.

Command line

shib run v-fmota -e '\,/\/\[/\/\./\/\,/\/\]/\/' --input 'cat'
shib manual v-fmota

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/v-fmota.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org