An expression which evaluates to either true or false is called a boolean expression. Boolean expressions are used extensively in programming language constructs such as if-then-fi commands and while loops. Darwin offers and, or and not for building such expressions. The and returns true if and only if both arguments are true. The not operator negates a boolean value.
> u := true: v := false: > (u and v); false > (u and (not v)); true > flag := true: > not((not flag) = (not not not flag)); falseThe or operator returns false if and only if both arguments are false.
> u := true: v := false: > (u or v); # one must be true for `or' > ((not u) or v); # u -> vWe can build more complex boolean expressions using these operators, expressions and the comparison operators. Table contains a list of all comparison and boolean operators.
> (6 = 1 + 2 + 3) and (720 = factorial(6)); true > x := 57: > (mod(x, 2) = 0) or (mod(x, 3) = 0) or (mod(x, 5) = 0); # is x divisible # by 2, 3, or 5? false > 5 < 7; true > floor(6.5) <= 6; true > 1 <> 2; true