esolang

VAR

Ten three-letter commands, and every value is a list of character codes.

machalvan · Turing complete: yes · ●○○ easy

Tested with 4 known programs · Hello World on Try It Online: identical except the line end · Test method

Run it

Expected: Hello, World!

The idea

VAR, by machalvan on GitHub, has one statement per line: a command, then maybe a variable, then maybe a value. Underneath, a number and a string are the same thing. 65 is the list [65] and "AB" is [65, 66]. So OUT 65 prints A, and printing a number as digits takes STR first.

The machine

CommandDoes
VAR x valueSet x; VAR x[i] value replaces one code
INP xRead a line into x
OUT value [flag]Print the codes as text, then a newline unless the flag is 0
INC x [n] DEC x [n]Add or take away, default 1
INT x STR xDigits to a number, a number to digits
WHL x … ENDLoop while the first code of x is not 0
CON x … ENDRun once if the first code of x is not 0

A value is an integer, a "string" without escapes, a variable, or x[i], one code of a variable, which is 0 past its end. // starts a comment. The reference is var.py in github.com/machalvan/VAR.

Example

The second copies the counter, turns the copy into digits and prints it.
Expected: 3 2 1
Expected: desserts

The second copies the counter, turns the copy into digits and prints it. The third finds the length of the input by reading codes until it meets the 0 past the end, then prints them backwards without newlines.

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from VAR

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run var -e 'OUT 72 0
OUT 105'
shib manual var

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/var.js

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