(-) subtraction operator. Sign change
X - Y -X
scalars, vectors, matrices, or hypermatrices of booleans, numbers,
polynomials or rationals.
They may also be some syslin lists.
Subtraction
For numeric operands, the subtraction has its usual meaning. If one of the operands is a scalar, then the substraction is performed with each component of the other operand.
As soon as a boolean is involved in a substraction with a number (decimal, complex,
or encoded integer), it is automatically converted in the type (and integer type)
of the number before performing the substraction or the sign change, as
%F => 0 and %T => 1.
Whatever is the (regular) type of X, then []-X,
X-[], and -[] return [].
The subtraction operator may be extended to other custom data types through the overloading mechanism.
--> [] - 2
ans =
[]
--> 1 - []
ans =
[]
--> [2, 5] - 1
ans =
1. 4.
--> [2, 5] - [3 -2]
ans =
-1. 7.
--> %s - 2
ans =
-2 +s
--> 1/%s - 2
ans =
1 - 2s
-------
s
With booleans:
--> -[%f %t] ans = 0. -1. --> [%f %f %t %t] - [%f %t %f %t] ans = 0. -1. 1. 0. --> %t - %i ans = 1. - i --> c = %t - int8(7), typeof(c) c = -6 ans = int8
| Version | Description |
| 6.0.0 | A - [] and [] - A now return
[] instead of A or -A. |