-
Notifications
You must be signed in to change notification settings - Fork 0
/
03_Logic_and_Relations.olly
92 lines (71 loc) · 2.09 KB
/
03_Logic_and_Relations.olly
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
##############################################################
True and false statements and relationships are easily
expressed using some simple operators. All of which
support postfix operators of all infix or prefix
operators.
First we will demonstrate infix and prefix boolean
operations.
##############################################################
#! NO_EXCEPT = false
let p = true
let q = false
"p = " << p << endl
"q = " << q << endl
endl
"p & q = " << (p & q) << endl
"p | q = " << (p | q) << endl
"p ^ q = " << (p ^ q) << endl
endl
let q = p
"p q and = " << (p q and) << endl
"p q or = " << (p q or) << endl
"p q xor = " << (p q xor) << endl
endl
######################################################
Eqaulity testing in both infix and postfix.
######################################################
let x = '1'
let y = '2'
"x = y = " << (x = y) << endl
"x -= y = " << (x -= y) << endl
"x <= y = " << (x <= y) << endl
"x < y = " << (x < y) << endl
"x >= y = " << (x >= y) << endl
"x > y = " << (x > y) << endl
endl
"x y eq = " << (x y eq) << endl
"x y ne = " << (x y ne) << endl
"x y le = " << (x y le) << endl
"x y lt = " << (x y lt) << endl
"x y ge = " << (x y ge) << endl
"x y gt = " << (x y gt) << endl
endl
######################################################
Postfix logical implication exampled below.
######################################################
let x = '42'
(x > '10') +:
("x is greater than 10" << endl)
("x is not greater than 10" << endl)
; imply
######################################################
Infix logical implication exampled below.
######################################################
let x = '-2'
(x > '10') then :
("x is greater than 10" << endl)
("x is not greater than 10" << endl)
;
######################################################
Prefix logical implication exampled below.
######################################################
let x = '10'
if (x > '10'):
"x is greater than 10" << endl
;
elif (x < '10'):
"x is less than 10" << endl
;
else:
"x is equal to 10" << endl
;