Operators

Operators use the precedence from Java, with the exception of the power operator, which comes from Python.

Operators can have values on the left and/or right, which Menter indicates by an interval-syntax:

  • ( ) round parenthesis show that there is a value on that side of the operator

  • [ ] square brackets show that there is no value on that side of the operator

The round parenthesis indicate where the values are that are transformed by the operator.

Examples for the - and ! operators:

  • -4
    [-) 4 the operator value is on the right side of the operator

  • 6 - 4
    6 (-) 4 there are values on both sides of the operator

And some more examples:

  • !true[!) true

  • 6!6 (!]

Find a full list of operators here.

Operator functions

Using the interval syntax above, operators can be transformed into functions that take either one or two arguments.

For example, the + operator can be transformed into a function that takes two arguments, or the ! operator with one argument.

add = (+) # store in function...;;;add(1, 2);;;(!](5) # ...or call directly

That way, operators can be passed as arguments to other functions.

range(1, 4).reduce((+));;;[1, 2, 3, 4].map((!])

Compound assignment operator

A special feature of Menter is, that the assignment operator can be combined with any other operator.
This is called a compound assignment operator.

x = 5;;;x += 2;;;x **= 3
x = [1, 2, 3];;;x ::= [4, 5, 6]

A quality of life feature regarding this is, that if the assigning variable is not defined, it will be initialized with the value of the right hand side.

a += 5;;;b ::= [2, 3];;;c **= 3