esolang

VD3

One command. A variable becomes the sum of three things, and that is all a program ever does.

2009 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 6 known programs · Test method

Run it

Expected: A

The idea

VD3 dates from 2009 and has a single command, W<-X^Y^Z, which sets W to X + Y + Z. Each term is a whole number or a variable. Everything else comes from three special variables. Setting PC jumps, reading IN takes a character from the input, and setting OUT prints one. A jump to a negative position ends the run.

Read the story

VD3 2.0 adds more variables and the ... mark. A command written ...W<-X^Y^Z also fills every empty position after it, so a jump far past the last line still lands on something. That turns a sum into a branch, and the specification uses it to build any two-counter machine, which makes VD3 2.0 Turing complete.

The machine

VariableReadSet
A B C D EIts value, 0 at the startStore
PCThe position of this commandJump there; below 0 stops
INThe code of the next input characterNot allowed
OUTThe last code printedPrint that character

Commands are counted from 0, one per line. Running past the last line stops the run, unless a ... command fills the positions there. Any name of letters is a variable, since the specification's own example uses F, and IN gives -1 at the end of the input.

Example

The jump skips position 1 and prints only the B.
Expected: B

The jump skips position 1 and prints only the B.

The jump if zero adds the input's code to 7 and takes away 48. A 0 lands on 7, which jumps to the 5 saved in E and prints A. A larger digit lands past 7, where the ... command jumps back to the 3 saved in F and prints B.

Expected: A

The cat prints each character and jumps back to 0. At the end of the input IN gives -1, which is no character, so the run stops there with an error.

Expected: cat

Patterns it teaches

Further

OISC

Write your own in Run Convert a program from VD3

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: vd3.

Command line

shib run vd3 -e 'OUT<-65^0^0'
shib manual vd3

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/vd3.js

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

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