Columnal Documentation: Table of Contents

Operators

Operator +Operator -Operator ;Operator ±Operator <>Operator =Operator =~Operator &Operator |Operator <Operator <=Operator /
operator +operator -(Number{u}+Number{u}-...)Number{u}

Adds or subtracts numbers. All the numbers must have no units, or the same units.

Plus cannot be used for non-numbers. Some other types:

ExamplesClick an example to insert it
1 + 2 + 36
10 - 2 - 3 + 16
operator ;(Text;Text...)Text

Joins text items together in order.

This operator can also be used in match expressions, usually to match and remove items from the beginning or end of a text item (see examples, below).

ExamplesClick an example to insert it
"a" ; "b" ; "c""abc"
@match "T-2000" @case "T-" ; y @then from text(y) @endmatch2000
operator ±(Number{uNumber{u})Number{u}

This is only valid in match cases or the right-hand side of the operator ~ operator.

It specifies a pattern that a number must be close to the left-hand operator, within the tolerance specified by the right-hand side.

ExamplesClick an example to insert it
(1 / 3) =~ (0.333 ± 0.001)trueDeal with inexact fractions by using a tolerance
operator <>(t<>t)Boolean

Tests whether two values are not-equal

ExamplesClick an example to insert it
3 <> 6true
operator =operator =~(t=t=~...)Boolean

Checks that all the items are equal.

Note that you can compare more than two items at once. The equals expression is true only if all the items are equal to each other.

Checks if the value on the left, matches the pattern on the right.

If there are no special patterns on the right-hand side (e.g. _, operator ±, new variables) then it is equivalent to operator =.

If you do declare a variable in the right-hand side, the variable will not be accessible outside the pattern. For that, use the full match expression.

ExamplesClick an example to insert it
1 = 2false
from text("1") = 1true
(2/2)=1=(2-1)true
"$50" =~ ("$" ; _)trueCheck if text starts with a dollar sign
50.0006 =~ (50 ± 0.01)trueCheck if number is close to another
["Hi", "there"] =~ ["", _]falseCheck if a list has two items, and the first is an empty text value
(low:2, high:4) =~ (low:x, high:(x + 2))trueCheck if the high item is exactly 2 higher than the low item
["Bye", "Bye"] =~ [s, s]trueCheck if a list has two values, and they are the same
operator &(Boolean&Boolean...)Boolean

Checks if all items are true.

The items are checked left-to-right and are not evaluated beyond the first false item. See the first example for how this is useful.

ExamplesClick an example to insert it
(list length([6, 7]) >= 2) & (element([6, 7], 2) = 5)falseWill not cause an error because list size is checked before getting the item.
("a" = "a") & ("a" <> "b")true
true & true & falsefalse
operator |(Boolean|Boolean...)Boolean

Checks if any items is true.

The items are checked left-to-right and are not evaluated beyond the first true item. See the first example for how this is useful.

ExamplesClick an example to insert it
(list length([6, 7]) >= 2) & (element([6, 7], 2) = 5)falseWill not cause an error because list size is checked before getting the item.
("a" = "b") | ("a" <> "b")true
true | true | falsetrue
operator <operator <=(t<t<=...)Boolean

Compares the values.

Note that you can chain multiple less-than and less-than-or-equals in the same expression.

The rules for different types are as follows:

ExamplesClick an example to insert it
1 < abs(-2) < 3true
false < truetrue
"mud" < "muddle"true
as type(type{DateTimeZoned}, from text("2013-05-02 12:00 Europe/London")) < from text("2013-05-02 11:37 America/Toronto")true
Optional\None < Optional\Is(0)true
(a:0, b:5) < (a:1, b:3)true
operator /(Number{u}/Number{v})Number{u/v}

Divides the left side by the right side.

This will produce a decimal component if necessary. If you want integer division, round the result.

The result will have appropriate units, dividing the top units by the bottom units.

ExamplesClick an example to insert it
5 / 22.5
round decimal((100{m} / 9.58{s}), 2)10.44{m/s}