Operators

MathMap operators are overloaded based on the types of their arguments. Arithmetic operators work as expected on real and on complex numbers. On tuples with the same length and tag they perform their operation element-wise. If their second argument is a tuple of length 1, they perform element-wise on the left operand always using the same right operand.

For example, [1,2,3]+[7,2,4] gives nil:[8,4,7], while [1,2,3]+1 gives nil:[2,3,4].

Relational and logical operators currently only work on tuples with length 1.

+
Addition
-
Subtraction
*
Multiplication. Matrix-matrix, matrix-vector and vector-matrix multiplication for 2x2 or 3x3 matrices is done when the matrix has the type m2x2:4 or m3x3:9, respectively.
/
Division. Vector-matrix division is done for 2x2 or 3x3 matrices when the matrix has the type m2x2:4 or m3x3:9, respectively.
%
Modulo. This also works with real numbers.
^
Exponentation. Does not perform on two tuples of length greater 1.
- (unary)
Arithmetic negation
==
Gives 1 if the operands are equal, otherwise 0.
!=
Gives 1 if the operands are not equal, otherwise 0.
<=
Gives 1 if the first operand is less or equal than the second, 0 otherwise.
>=
Gives 1 if the first operand is greater or equal than the second, 0 otherwise.
<
Gives 1 if the first operand is less than the second, 0 otherwise.
>
Gives 1 if the first operand is greater than the second, 0 otherwise.
||
Returns 1 if at least one of the operands is not 0, otherwise 0.
&&
Returns 1 if both of the operands is not 0, otherwise 0.
! (unary)
Returns 1 if the operand is 0, 0 otherwise.
;
Evaluates both operands (first the left one, then the right one) and gives the value of the second.