Skip to content

Expressions

Expressions are used in dispatch displays, charts and tables. In the dispatch context they access data attributes through the values object.

Example, calculate BMI from metric weight and height.

values.weight / (values.height) ^ 2

Syntax

Operator Name Syntax Associativity Example Result
(, ) Grouping (x) None 2 * (3 + 4) 14
[, ] Matrix, Index [...] None [[1,2],[3,4]] [[1,2],[3,4]]
{, } Object {...} None {a: 1, b: 2} {a: 1, b: 2}
, Parameter separator x, y L🡒R max(2, 1, 5) 5
. Property accessor obj.prop L🡒R obj={a: 12}; obj.a 12
; Statement separator x; y L🡒R a=2; b=3; a*b [6]
; Row separator [x; y] L🡒R [1,2;3,4] [[1,2],[3,4]]
\n Statement separator x \n y L🡒R a=2 \n b=3 \n a*b [2,3,6]
+ Add x + y L🡒R 4 + 5 9
+ Unary plus +y L🡐R +4 4
- Subtract x - y L🡒R 7 - 3 4
- Unary minus -y L🡐R -4 -4
* Multiply x * y L🡒R 2 * 3 6
.* Element-wise multiply x .* y L🡒R [1,2,3] .* [1,2,3] [1,4,9]
/ Divide x / y L🡒R 6 / 2 3
./ Element-wise divide x ./ y L🡒R [9,6,4] ./ [3,2,2] [3,3,2]
%, mod Modulus x % y L🡒R 8 % 3 2
^ Power x ^ y L🡐R 2 ^ 3 8
.^ Element-wise power x .^ y L🡐R [2,3] .^ [3,3] [8,27]
' Transpose y' L🡒R [[1,2],[3,4]]' [[1,3],[2,4]]
! Factorial y! L🡒R 5! 120
& Bitwise and x & y L🡒R 5 & 3 1
~ Bitwise not ~x L🡐R ~2 -3
\| Bitwise or x \| y L🡒R 5 \| 3 7
^\| Bitwise xor x ^\| y L🡒R 5 ^\| 2 7
<< Left shift x << y L🡒R 4 << 1 8
>> Right arithmetic shift x >> y L🡒R 8 >> 1 4
>>> Right logical shift x >>> y L🡒R -8 >>> 1 2147483644
and Logical and x and y L🡒R true and false false
not Logical not not y L🡐R not true false
or Logical or x or y L🡒R true or false true
xor Logical xor x xor y L🡒R true xor true false
= Assignment x = y L🡐R a = 5 5
? : Conditional expression x ? y : z L🡐R 15 > 100 ? 1 : -1 -1
: Range x : y L🡐R 1:4 [1,2,3,4]
to, in Unit conversion x to y L🡒R 2 inch to cm 5.08 cm
== Equal x == y L🡒R 2 == 4 - 2 true
!= Unequal x != y L🡒R 2 != 3 true
< Smaller x < y L🡒R 2 < 3 true
> Larger x > y L🡒R 2 > 3 false
<= Smallereq x <= y L🡒R 4 <= 3 false
>= Largereq x >= y L🡒R 2 + 4 >= 6 true

Functions

  1. mad(..) - Median absolute deviation
  2. max(..) - Maximum value
  3. mean(..) - Mean value
  4. median(..) - Median value
  5. min(..) - Minimum value
  6. mode(..) - Mode
  7. prod(..) - Product
  8. std(..) - Standard deviation
  9. sum(..) - Compute the sum
  10. variance(..) - Maximum value