3var
3var is an esoteric programming language designed by User:LuaGeek2412, with the goal of being as capable as other esolangs, but being much easier to make an interpreter for. It is heavily inspired by esolang Deadfish.
Suggestions are welcome.
Language Overview
3var has - you guessed it - 3 variables! All of them store integers. 2 of the variables are called the accumulators, and the third is called the result. The accumulators will be referred to as A and B, and the result as R. 3var has quite a few commands, all of which are a single ASCII character to fulfill the goal of being easy to interpret. These commands are:
i Increments A d Decrements A s Squares A p Prints A P Prints the ASCII character associated with A x Sets A to the absolute value of A > Sets A to R a Increments B k Decrements B m Squares B o Prints B O Prints the ASCII character of B 0 Sets B to the absolute value of B < Sets B to R + Adds A and B, stores in R - Subtracts B from A, stores in R * Multiplies A and B, stores in R / Divides A by B, stores in R ^ Exponentiates A to the Bth power, stores in R w Prints R u Marks a conditional which executes only if a>b U Marks a conditional which executes only if a<b = Marks a conditional which executes only if a==b ( Starts an if statement body ) Ends an if statement body | Marks a loop which executes while a>b _ Marks a loop which executes while a<b \ Marks a loop which executes while a==b f Marks a loop which executes a times F Marks a loop which executes B times { Starts a loop which repeats forever } Ends a loop which repeats forever [ Starts a marked loop ] Ends a marked loop ' Takes a 1 character input from the user and stores the ASCII value of the character in R " Takes a number input from the user and stores it in R r Resets all variables to 0 @ Resets A to 0 # Rests B to 0 e Resets R to 0 $ Toggles comment ~ Starts a line comment ` Causes the interpreter to ignore the next character
All other characters throw errors, unless enclosed in a comment.
Language Standards
- Use of R as a full variable is discouraged, but allowed
- All variables can contain any number
Computational Class
3var is Turing-complete if and only if its variables are unbounded. Bounds on the variables are not specified and therefore implementation-dependent.[Proof?]
Examples
Hello, World!
Legitimate Hello, World! with the exclamation point and everything.
iisssaa/>e maa->e# aamam->e# dddddddddddddddddddddddddPiiiiiiiiiiiiiiiiiiiiiiiii iiiiPiiiiiiiPPiiiP r iis aamaaaa *>P r iisssaa/>e maa->e# aamam->e# iiiiiiiiiiiiiiiiiiiiiiP ddddddddP iiiP ddddddP ddddddddP r iiss aa*> iP
Cat
This one is shorter. I promise.
{'>P}
Don't ask me to make it accept multiple characters before outputting.
Countdown
An example of a marked loop. Counts down from 100 to 1.
iiisis |[ pd ]
The first line sets the starting value for A (100). It then sets B to the minimum value. Then, while a>b, it outputs a and decrements it.
Parity
Takes a number input and calculates if it is even or odd.
"> ~Take a number input and move it to a. |[ ~While a>b do... aa ~b+=2 ] =( ~if a==b... riiisisi `1`0`1 P `e r ) U( ~if b>a... riiisia+<*>i `1`1`1 P `o r )
Pretty self explanatory.
Conditional Cat
Copies input to output until a newline character is input.
i ~Set a to 1 |[ ~While a>0 do... '<O ~Read in a character to b and output @iiisi ~Set a to 10 ->x ~Set a to |a-b| # ~Set b back to zero for loop condition ]
99 Bottles of beer
Prints 99 Bottles of beer in 3var
aaa m a m k f [ o @ iii s s ddddd ddddd ddddd P @ iii s ii s ddddd ddddd P iiiii P P ddddd ddd P ddddd dd P iiiii iiiii iiii P @ iiiii i s dddd P @iii s ii s ddddd ddddd P ddddd dddd P @ iiiii i s dddd P iii s i s dd P iii P P iiiii iiiii iii P @ iiiii i s dddd P @ iii s ii s ddddd ddddd P d P @ iiiii i s dddd P @ iii s ii s ddddd P ddddd ddddd dd P ddd P @ iiiii i s dddd P @ iii s ii s dd P @ iii s i s ddd P iiiii iiiii i P P @ iiiii ii s ddddd P @ iiii s ddd P o @ iii s i s dd P @ iii s ii s ddddd ddddd P iiiii P P ddddd ddd P ddddd dd P iiiii iiiii iiii P @ iiiii i s dddd P @iii s ii s ddddd ddddd P ddddd dddd P @ iiiii i s dddd P iii s i s dd P iii P P iiiii iiiii iii P @ iiiii ii s ddd P @ iiii s ddd P @iii s i s ddddd ddddd ddddd d P iiiii iiiii iii P iiiii iiiii P ddddd d P @ iiiii i s dddd P @iii s i s iiiii iiiii i P d P ddddd dddd P @ iiiii i s dddd P @iii s i s P iiiii iiiii i P iiiii iii P ddddd dddd P @ iiiii i s dddd P iii s i s ddd P iiiii iiiii iii P ddddd ddddd P @ iiiii i s dddd P iiisi s iiiii iiiii ii P @ iii s i s ddd P @ iii s ii s ddddd d P P @ iiiii i s dddd P iii s i s iiiii P iiiii iiiii i P @ iiiii i s dddd P @ iii s i s ddd P @ iii s ii s ddddd dd P ddd P iiiii i P ddddd dd P ddddd ddddd P @ iiiii ii s ddddd P @ iiii s ddd P k o @ iii s s ddddd ddddd ddddd P @ iii s ii s ddddd ddddd P iiiii P P ddddd ddd P ddddd dd P iiiii iiiii iiii P @ iiiii i s dddd P @iii s ii s ddddd ddddd P ddddd dddd P @ iiiii i s dddd P iii s i s dd P iii P P iiiii iiiii iii P @ iiiii i s dddd P @ iii s ii s ddddd ddddd P d P @ iiiii i s dddd P @ iii s ii s ddddd P ddddd ddddd dd P ddd P @ iiiii i s dddd P @ iii s ii s dd P @ iii s i s ddd P iiiii iiiii i P P @ iiiii ii s ddd P @ iiii s ddd P P @ iii s i s dd ]
Might not be as short as it could be but it gets the job done
99 Bottles Code by User:AzyMyt Somebody please make a better one
External resources
- An interpreter written in C.