Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Operators

Complete operator reference

Logical operators

OperatorMeaningExample
andLogical ANDx > 0 and y > 0
orLogical ORx > 0 or y > 0
notLogical NOTnot active
impliesImplication(x > 0) implies (y > 0)
iffIf and only ifx == 0 iff y == 0

Comparison operators

OperatorMeaning
==Equal
!=Not equal
<Less than
<=Less than or equal
>Greater than
>=Greater than or equal

Arithmetic operators

OperatorMeaning
+Addition
-Subtraction
*Multiplication
/Integer division
%Modulo

Set operators

OperatorMeaningType
inMembershipT, Set[T] -> Bool
not inNon-membershipT, Set[T] -> Bool
unionUnionSet[T], Set[T] -> Set[T]
intersectIntersectionSet[T], Set[T] -> Set[T]
diffDifferenceSet[T], Set[T] -> Set[T]
subset_ofSubset testSet[T], Set[T] -> Bool

Sequence operators

Operator/FunctionMeaningType
++ConcatenationSeq[T], Seq[T] -> Seq[T]
s[i]Index accessSeq[T], Int -> T
s[lo..hi]SliceSeq[T], Int, Int -> Seq[T]

Built-in functions

FunctionMeaningType
len(x)Length/sizeSeq[T] -> Int or Set[T] -> Int
head(s)First elementSeq[T] -> T
tail(s)All but firstSeq[T] -> Seq[T]
keys(d)Dict keysDict[K,V] -> Set[K]
values(d)Dict valuesDict[K,V] -> Set[V]
powerset(s)All subsetsSet[T] -> Set[Set[T]]
union_all(s)Flatten setsSet[Set[T]] -> Set[T]

Dict operators

OperatorMeaning
d[k]Access value at key k
d1 | d2Merge (d2 values override d1)