Boolean logic with
You can test multiple conditions using boolean logic.
Boolean logic refers to combining and changing the results of predicates using
It follows the common sense way you look at things.
Is this and that true? Only if both are true. Is this or that true?
Yes, if either -- or both! -- are. Is this not true? Yes, if it's false.
Truthy and falsey table
not can be combined to create a more complex condition.
Here is an example containing several conditions for confirming if a calendar year is a leap year.
(defn leap-year? "Every four years, except years divisible by 100, but yes for years divisible by 400." [year] (and (zero? (mod year 4)) (or (zero? (mod year 400)) (not (zero? (mod year 100)))))) ;; (leap-year? 1984)
Try explain this function to another student
If it seems complicated, take each of the conditions by themselves to see what they do. Try the conditions with different years
If you get stuck with the exercise, ask a volunteer to help.