BareMinimum

From Esolang
Jump to: navigation, search

BareMinimum is a programming language with only two operators: subtract and minimum.

Expressions

All expressions in BareMinimum are in prefix notation. There are two binary operators: - and +. - is the usual binary subtraction operator, and + returns the minimum of its arguments. Integer constants and variables are also supported. Spaces can be used to separate arguments

Statements

There are three kinds of statements in BareMinimum: variable, loop, and output.

Variables

Variables are defined using the = assignment operator like so: var = expr Variables can be accessed by simply putting their name.

Loop

Loops are done by typing a variable name, and an opening curly brace. Then enter some statements and a closing curly brace. For example:

x{
x = y
}

The variable's value will be queried each time the loop is run and if it equals zero the loop will end, otherwise the loop will repeat.

Output

Simply typing an expression without an equal sign will output the value of the expression.

Comments

A line starting with a space becomes a comment and is not executed.

Examples

Useful subexpressions

 x+y
z = -x-0y
 max(x,y)
z = -0+-0x-0y
 abs(x)
z = --0+0-0x+0x
 x == y (0 or 1)
z = +1--0+0-0-x y+0-x y