Skip to content

Arithmetics expressions¤


!ADD: Addition¤

Type: Sequence

You can add following types:

  • Numbers (Integers and floats)
  • Strings
  • Lists
  • Sets
  • Tuples
  • Records

Example

!ADD
- 4
- -5
- 6

Calculates 4+(-5)+6, the result is 5.


!SUB: Substraction¤

Type: Sequence

Example

!SUB
- 3
- 1
- -5

Calculates 3-1-(-5), the result is 7.


!MUL: Multiplication¤

Type: Sequence

Example

!MUL
- 7
- 11
- 13

Calculates 7*11*13, the result is 1001 (which happens to be the Scheherazade constant).


!DIV: Division¤

Type: Sequence

Example

!DIV
- 21
- 1.5

Calculates 21/5, the result is 14.0.

Division by zero¤

Division by zero produces the error, which can cascade thru the expression.

!TRY expression can be used to handle this situation. The first item in !TRY is a !DIV that can produce division by zero error. The second item is a value that will be returned when such an error occurs.

!TRY
- !DIV
  - !ARG input
  - 0.0
- 5.0

!MOD: Remainder¤

Type: Sequence

Calculate the signed remainder of a division (aka modulo operation).

Info

Read more about modulo on Wikipedia.

Example

!MOD
- 21
- 4

Calculates 21 mod 4, the result is 1.

Example

!MOD
- -10
- 3

Calculates -10 mod 3, the result is 2.


!POW: Exponentiation¤

Type: Sequence

Calculate the exponent.

Example

!POW
- 2
- 8

Calculates 2^8, the result is 16.


!ABS: Absolute value¤

Type: Mapping

!ABS
what: <x>

Calculate the absolute value of input x, which is the non-negative value of x without regard to its sign.

Example

!ABS
what: -8.5

The result is a value 8.5.