Several built-in, infix operators allow testing for equality and inequality. For numbers,
!= are used. For strings,
like are used.
The following are all valid predicate expressions:
As can be seen from the preceding examples, a number of built-in libraries provide predicates that can be used inside predicate expressions. The documentation for those libraries gives details about their operation.
Two special comparison operators are useful with the sort() operator:
cmp. These operators return -1 if the first operand is less than the second, 0, if they're equal, and 1 if the first operand is greater than the second.The
<=> operator is used with numbers and
cmp is used with strings.
Like takes a regular expression as its second argument and returns true if it matches the string given as its first argument. Arguments to these operators can be any valid expression.
Note that when the
There is an infix operator for testing membership,
><. The >< operator tests the number or string in the right operand for membership in the map or array given by the left operand. For maps, membership extends to keys only.
Compound predicate expressions are created using the operators
not to express conjunction, disjunction, and negation, respectively. Conjunction has precedence over disjunction. Parentheses are used to group expressions for precedence.