esolang

Three variable modification language

Three variables, a = 3, b = -2 and c = -1, and no other number. Every value has to be made from them.

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

Tested with 2 known programs · Test method

Run it

Expected: 100

The idea

There are no literals and no input. The only numbers are the three variables, and the only way to change one is to combine it with another. +ab works out a + b and stores it in b, the second variable named. So every constant a program needs is built from 3, -2 and -1, and a program that has used up a variable can set it back to its start with R.

Read the story

The specification shows that it is Turing complete. +ba-bb-cc leaves 1 in a and 0 in b and c, and then b and c are the two registers of a Minsky machine, with a as the 1 to add and take away.

The machine

CommandDoes
+xy -xy *xy /xyWork out x + y, x - y, x * y or x / y and store it in y
>x <xPrint x as a number or as a character
!xNegate x
RxSet x back to its start
w[x ... ]Repeat while x is above 0
i[x ... ]Run once if x is 0 or less

Whitespace is ignored. The specification does not say how / rounds; this implementation drops the fraction.

Example

The set-up for its Minsky machines, made to print.

The set-up for its Minsky machines, made to print.

The Hello World. *aa makes a = 9, *ac makes c = -9, *cc makes c = 81 and -ca makes a = 81 - 9, which is 72, the H.

Expected: Hello, World!

A loop counts down from 9. Rc makes c = -1 again and +ca adds it to a.

Expected: 987654321

The 99 bottles of beer program is 107 lines long. It makes 99 as 11 times 9, and builds every character in b one bit at a time. Rc!c makes c = 1, -bb makes b = 0, and then +bb doubles b and +cb adds 1. It prints the whole song.

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from Three variable modification language

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: three-variable-modification-language.

Command line

shib run three-variable-modification-language -e '*aa*ac*cc-ca<aRa-ba*ba*ba-ca<aRc+bc+bb+bc-ac<c<cRa+ac<c/caRbRc+bc+bb+bc-ac<cRc+bc+ac<cRa*ac*aa-ca<aR
a*ab-bc-ac<c+ca<aRa-ca<aRb+bb+bb+ab<bRbRc*bb*bb+bb-bc<c'
shib manual three-variable-modification-language

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/three-variable-modification-language.js

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

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