2.15 Logical Operators
In order to combine logical expressions together, we have the conjunction &&, the disjunction ||, and the negation ! operators. While the conjunction and the disjunction operators take two arguments and are written in infix notation, the negation operator takes just one argument in prefix notation. The value of such combinations is determined by the following rules:
&& evaluates arguments from left to right until one of them is false, in which case it returns false. If none of the arguments are false, the && operator returns true;
|| evaluates arguments from left to right until one of them is true, in which case it returns true. If none of the arguments are true, the || operator returns false;
! evaluates to true if the argument is false, and evaluates to false if the argument is true.
2.15.1 Exercises 7
2.15.1.1 Question 21
(2 > 3 || !(2 == 3)) && 2 < 3
!(1 == 2 || 2 == 3)
1 < 2 || 1 == 2 || 1 > 2
2.15.2 Exercises 8
2.15.2.1 Question 22
What is a conditional expression? What is a logical expression?
2.15.2.2 Question 23
What is a logical value? Which logic values does Julia provide?
2.15.2.3 Question 24
What is a predicate? Give examples of predicates used in Julia.
2.15.2.4 Question 25
What is a relational operator? Give examples of relational operators used in Julia.
2.15.2.5 Question 26
What is a logical operator? Give examples of logical operators used in Julia.
2.15.2.6 Question 27
What is a recognizer? Give examples of recognizers in Julia.
2.15.2.7 Question 28
\(x<y\)
\(x\leq y\)
\(x<y\wedge y<z\)
\(x<y\wedge x<z\)
\(x\leq y \leq z\)
\(x\leq y < z\)
\(x< y \leq z\)