We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

OneVar

From Esolang
Jump to navigation Jump to search

OneVar is an esolang invented by User:None1. As its name states, it uses only one variable (signed integer initially 0), whose name is _, but you can do a lot of things to it.

Commands

There are two types of commands: variable assignment and conditional jumping. They're separated by line feeds.

Variable assignments are like this:

_=expression

Self-explanatory.

Conditional jumps are like this:

expression$offset

If expression is nonzero, add line number by offset instead of moving on to the next line.

Output (Optional):

./:

Prints _ as ASCII character/integer.

Input (Optional):

,/;

Reads _ as ASCII character/integer.

Operators

OneVar has many operators: +,-,*,/(Floor division),%,**,&,|,^,~,(),<<,>>,>,<,==,!=,>=,<=. Operator precedences are the same as that of Python. You can use integer literals (decimal only) as well.

Examples

Infinite loop

~_$0;

Computational class

If OneVar supported floats, it would be Turing complete for we can fit two accumulators in one variable and implement a Minsky machine. However, with integers, its computational class is unknown, but at least a PDA.