Loading

-


operators
Since v1.0.0
Available on all platforms
See also

Subtracts two parameters.

The - operator consumes two parameters from the top of the stack and pushes back the result of subtracting the second one from the first one.

  • If both parameters are numbers, the result is the subtraction of both numbers.

  • If both parameters are vectors, the - operator subtracts each element of vectors which are on the same index. Vectors must be the same size.

  • If both parameters are matrices, the - operator subtracts each element of matrices which are on the same index. Matrices must be the same size.

Signature

Examples

// Subtracting numbers 2 5 - 2.5 3.14 - 4.14 1 - 1 4.14 - // Subtracting vectors // Vectors are not printable so we convert them into a list for this example [ 1 2 3 ] ->VEC 'vector1' STORE // Create first vector [ 4 5 6 ] ->VEC 'vector2' STORE // Create second vector $vector1 $vector2 - VEC-> $vector2 $vector1 - VEC-> $vector2 $vector2 - VEC-> // Subtracting matrices // Matrices are not printable so we convert them into a list for this example [ [ 1 2 ] [ 3 4 ] ] ->MAT 'matrix1' STORE // Create first matrix [ [ 3 4 ] [ 5 6 ] ] ->MAT 'matrix2' STORE // Create second matrix $matrix1 $matrix2 - MAT-> $matrix2 $matrix1 - MAT-> $matrix2 $matrix2 - MAT->