website logo
Navigate through spaces
ChartHop documentation
⌘K
ChartHop Help Center
Getting around in ChartHop
ChartHop for Employees
Implementing ChartHop
ChartHop for Administrators
Carrot reference
ChartHop for Developers
Partners
Release notes
Resources
Docs powered by
Archbee
website logo
Carrot reference
Elements of Carrot expressions

Operators

An operator in Carrot is one or more symbols or words that compare the value of a field on its left with one or more values (or functions) on its right. The valuation of the clause will always result as true.

Carrot operators understand money-math and automatically convert currencies when adding or subtracting two different currencies.

Operator list

Name

Function

+ (add)

An operator used to add two or more expressions.

- (subtract)



An operator used to subtract an expression from another expression.

* (multiply)

An operator used to multiply two or more expressions.

/ (divide)

An operator used to divide one expression by another.

% (modulus)

An operator used to calculate the remainder of a division operation.

= (equals)

Returns true when the value of a given field and a given expression are the same.

!= (not-equals)

Returns all records where the value of a given field and a given expression are not the same.

! (not)

Invalidates the truthiness of an evaluated expression.

> (greater-than)

Returns all records where the value of one expression or field is greater than the value of another expression or field.

>= (greater-than-equals)

Returns all records where the value of one expression or field is greater than or equal to the value of another expression or field.

< (less-than)

Returns all records where the value of one expression or field is less than the value of another expression or field.

<= (less-than-equals)

Returns all records where the value of one expression or field is less than or equal to the value of another expression or field.

[ ](array)

Access a given expression as an array, and return a defined position on that array.

Operator precedence

When an expression makes use of more than one operator, Carrot relies on a set of rules to determine the order in which each operator is evaluated. Carrot follows a standard order of operations when evaluating an expression based on operator precedence. Operators that have a higher precedence in the table below will be evaluated first.

Precedence

Operator

Associativity

9

[ ](array) . (dot)

left to right

8

! (not)

right to left

7

* (multiply) / (divide) % (modulus)

left to right

6

+ (add) - (subtract)

left to right

5

< (less-than) <= (less-than-equals) > (greater-than) >= (greater-than-equals)

not associative

4

: (match)

= (equals)

!= (not-equals)

left to right

3

&& (and)

left to right

2

|| (or)

left to right

1

? (ternary) ?: (elvis)

right to left

Consider the expression below.

variableA * variableB + variableC

Without operator precedence, Carrot would not know which operation to complete first. If we refer to the table above, we see that multiplication has a higher precedence than addition. Thus, variableA * variableB is evaluated first, then the result of that expression is added to variableC.

Of course, addition and multiplication are two well known examples of operator precedence in arithmetic, and it works in the same way in Carrot. Just like arithmetic, if you wanted to change the precedence of the above expression, you would use parenthesis as illustrated below.

variableA * (variableB + variableC)

In the above expression, we are telling Carrot to explicitly add variableB to variableC before multiplying the result by variableA.

Updated 18 May 2023
Did this page help you?
PREVIOUS
year()
NEXT
+ (add)
Docs powered by
Archbee
TABLE OF CONTENTS
Operator list
Operator precedence
Docs powered by
Archbee