-
Notifications
You must be signed in to change notification settings - Fork 0
/
bool.go
97 lines (81 loc) · 1.18 KB
/
bool.go
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
93
94
95
96
97
package ops
import "github.com/blackchip-org/zc/v5/pkg/zc"
/*
oper and
func AndBool p0:Bool p1:Bool -- Bool
title Logical conjunction
desc
The logical conjunction of *p0* and *p1*.
end
example
c true true and -- true
c true false and -- false
c false false and -- false
end
*/
func AndBool(c zc.Calc) {
a1 := zc.PopBool(c)
a0 := zc.PopBool(c)
r0 := a0 && a1
zc.PushBool(c, r0)
}
/*
oper false
func - -- Bool
macro [false]
title False
desc
Places `false` on the stack
end
example
false -- false
end
*/
/*
oper not
func NotBool Bool -- Bool
title Negation
desc
If `true`, returns `false`, otherwise returns `true`.
end
example
true not -- false
not -- true
end
*/
func NotBool(c zc.Calc) {
a0 := zc.PopBool(c)
r0 := !a0
zc.PushBool(c, r0)
}
/*
oper or
func OrBool p0:Bool p1:Bool -- Bool
title Logical disjunction
desc
The logical disjunction of *p0* and *p1*.
end
example
c true true or -- true
c true false or -- true
c false false or -- false
end
*/
func OrBool(c zc.Calc) {
a1 := zc.PopBool(c)
a0 := zc.PopBool(c)
r0 := a0 || a1
zc.PushBool(c, r0)
}
/*
oper true
func - -- Bool
macro [true]
title False
desc
Places `true` on the stack
end
example
true -- true
end
*/