-
Notifications
You must be signed in to change notification settings - Fork 0
/
4_boolFns.hs
47 lines (37 loc) · 1012 Bytes
/
4_boolFns.hs
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
46
47
-- * Native Boolean Functions
-- Logic operators return Booleans
-- * Logic Operators
-- && - Boolean and. Returns True if both the boolean to its left and right are True
-- || - Boolean or. returns True if either one of them is True
-- not - negate
-- True
-- False
-- == - equal
-- /= - not equal
-- && aka the and operator
logicalAnd = True && False --False
andFalse x = x && False
-- || aka the or operator
logicalOr = True || False --True
orFalse x = x && False
-- not will negate a value
logicalNot = not True --False
flipBool x = not x
-- Check for equality
equalTo = 10 == 10 --True
equalTo18 x = x == 18
-- Check for non equality
notEqualTo = 10 /= 10 --False
notEqualTo18 x = x /= 18
-- Less than
lessThan = 10 < 11 --True
lessThan18 x = x < 18
-- Less than or equal to
lessOrEqual = 10 <= 10 --True
lessOrEqualTo18 x = x <= 18
-- Greater than
greaterThan = 10 > 4 --True
greaterThan18 x = x > 18
-- Greater than or equal to
greaterOrEqual = 10 >= 10 --True
greaterOrEqualTo18 x = x >= 18