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 by trivial reduction by Oddjump.

If OneVar supports integers only, it would also be Turing complete because you have *,/,ans %, so by Godel numbering you can simulate an infinity-register Minsky machine.

Interpreter

code=`
`
input=``

_=0n;ip=0;code=code.split`
`.map(e=>(e=='.'?'process.stdout.write(String.fromCodePoint(Number(e%1114112n)))':
e==':'?'console.log(e)':
e==','||e==';'?'throw"input not supported";':
/\$/.exec(e)?`if(${e.split`$`[0]})ip+=-1+{${e.split`$`[1]}}`:
'_='+e.replace(/\d+/g,e=>e+'n'))+';ip++')
while(ip>=0&&ip<code.length)eval(code[ip])

See also