Loading

+

math operators

The + operator consumes two parameters from the top of the stack and pushes back the result of adding them.

The meaning of adding depends on the type of parameter:

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

  • If both parameters are strings, the result is the concatenation of both strings.

  • If both parameters are byte arrays, the result is the concatenation of both byte arrays (version 2.1+).

  • If the first parameter is a list, the + operator clones the list and appends the second parameter to the cloned list.

  • If the first parameter is a set, the + operator clones the set and appends the second parameter to the cloned set.

  • If both parameters are macros, the result is a macro concatenating the two others in any other case + with throw an exception.

  • If the first parameter is a vector, the + operator adds the second numeric parameter to each element of the vector.

  • If the second parameter is a vector, the + operator adds the first numeric parameter to each element of the vector.

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

  • If the first parameter is a matrix, the + operator adds the second numeric parameter to each element of the matrix.

  • If the second parameter is a matrix, the + operator adds the first numeric parameter to each element of the matrix.

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

  • If one of the parameters is a Geo Time Series™, the result will be a Geo Time Series™ of type DOUBLE.

+ is available since version 1.0.0.

See also

Signatures

Examples

// Adding numbers 2 2 + 1.10 2.04 + 2 1.14 + 2.14 1 + // Adding strings // All parameters must be strings 'Hello ' 'world' + // 'Hello ' 42 + // Won't work // 25 'days' + // Won't work // Adding lists [ 1 2 ] 3 + [ 1 2 ] 3.5 + [ 1 2 ] 'three' + [ 1 2 ] [ 4 5 6 ] + [ 1 2 ] { 'a' 1 } + // Adding sets // SET are not printable so we convert them into a list for the example ( 1 2 ) 3 + SET-> ( 1 2 ) 3.5 + SET-> ( 1 2 ) 'three' + SET-> ( 1 2 ) [ 4 5 6 ] + SET-> ( 1 2 ) { 'a' 1 } + SET-> // Adding vectors // VEC are not printable so we convert them into a list for the example [ 1 2 ] ->VEC 3 + VEC-> 3 [ 1 2 ] ->VEC + VEC-> [ 1 2 ] ->VEC 3.5 + VEC-> 3.5 [ 1 2 ] ->VEC + VEC-> [ 1 2 3 ] ->VEC [ 4 5 6 ] ->VEC + VEC-> // Adding matrices // MAT are not printable so we convert them into a list for the example [ [ 1 2 ] [ 3 4 ] ] ->MAT 10 + MAT-> 10 [ [ 1 2 ] [ 3 4 ] ] ->MAT + MAT-> [ [ 1 2 ] [ 3 4 ] ] ->MAT 20.5 + MAT-> 20.5 [ [ 1 2 ] [ 3 4 ] ] ->MAT + MAT-> [ [ 1 2 ] [ 3 4 ] ] ->MAT [ [ 10 20 ] [ 30 40 ] ] ->MAT + MAT->