Lesson 6. Logic operations
There are three basic logic operations that a programmer manipulates on a daily basis: negation, disjunction and conjunction also named logical not, logical or and logical and.
In many languages, we have a symbol for each operation:
- ! for logical not
- && for logical and
- || for logical or
In Clojure, we use the operation name itself:
- not for logical not
- and for logical and
- or for logical or
The fact that we use the operation name itself makes the code more readable.
In this lesson, we will introduce the two boolean values: true and false, and get a first introductory meeting with the Clojure null value: nil.
The most natural arguments for logic operations are the booleans. But Clojure being a dynamically typed programming language, it doesn’t limit the usage of logic operations to booleans. In this Lesson, we will learn how numbers and nil are handled by logic operations.
After completing this lesson, you will be able to:
- Understand Clojure expressions that deal with logic conditions involving one logic operation
- Write Clojure expressions that deal with logic conditions involving one logic operation
- Understand Clojure expressions that deal with logic conditions involving several logic operations
- Write Clojure expressions that deal with logic conditions involving several logic operations