-
-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathboolean.clj
42 lines (32 loc) · 759 Bytes
/
boolean.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
;; Ask if the value is nil
(nil? nil)
(nil? 1)
(nil? true)
(nil? false)
(nil? "hello")
;; nil and false as logical falsiness
(if nil
(println "not going to print")
(println "going to print"))
(if false
(println "not going to print")
(println "going to print"))
;; the rest of the values as truthy
(if "the truthy"
(println "going to print")
(println "not going to print"))
(if true
(println "going to print")
(println "not going to print"))
(if 1
(println "going to print")
(println "not going to print"))
;; equality operator: =
(= 1 1)
(= nil nil)
(= 1 2)
;; boolean operators: "or" and "and"
(or nil false true "string" 1)
(or (= 1 1) (= "string" "strong"))
(and nil false true "string" 1)
(and (= 1 1) (= "string" "strong"))