aboutsummaryrefslogtreecommitdiffstats
path: root/examples/booleans.bdl
blob: d248bf8a3dad892480f05c091555508a98c96a8a (plain)
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
43
44
45
;;
;; Boolean primitives.
;;

;; Boolean test.
(print "(boolean? true) -> ")   (boolean? true)
(print "(boolean? false) -> ")   (boolean? false)
(print "(boolean? 1) -> ")   (boolean? 1)
(print "(boolean? 5) -> ")   (boolean? 5)
(print "(boolean? \"string\") -> ") (boolean? "string")
(print "(boolean? (+ 1 2 3)) -> ")   (boolean? (+ 1 2 3))
(print "(boolean? (not 1)) -> ")   (boolean? (not 1))

;; Not.
(print "(not true) -> ")   (not true)
(print "(not false) -> ")   (not false)
(print "(not (not true)) -> ")   (not (not true))
(print "(not (not false)) -> ")   (not (not false))
(print "(not 1) -> ")   (not 1)
(print "(not (not 1)) -> ")   (not (not 1))
(print "(not \"string\") -> ") (not "string")
(print "(not (not \"string\")) -> ") (not (not "string"))

;; And.
(print "(and 1 \"string\" 4 true) -> ") (and 1 "string" 4 true)
(print "(and true true true) -> ")   (and true true true)
(print "(and (+ 1 2 3)) -> ")   (and (+ 1 2 3))
(print "(and false false false) -> ")   (and false false false)
(print "(and true false false) -> ")   (and true false false)
(print "(and false true false) -> ")   (and false true false)
(print "(and false true true) -> ")   (and false true true)
(print "(and (not false) true true) -> ")   (and (not false) true true)

;; Or.
(print "(or 1 \"string\" 4 true) -> ") (or 1 "string" 4 true)
(print "(or false 1) -> ")   (or false 1)
(print "(or false \"string\") -> ") (or false "string")
(print "(or false) -> ")   (or false)
(print "(or true true true) -> ")   (or true true true)
(print "(or false false false) -> ")   (or false false false)
(print "(or true false false) -> ")   (or true false false)
(print "(or false true false) -> ")   (or false true false)
(print "(or false true true) -> ")   (or false true true)
(print "(or (not false) true true) -> ")   (or (not false) true true)
(print "(or (not true) false) -> ")   (or (not true) false)