blob: 41747124fa1830c86287381986f9525a4b773c45 (
plain) (
blame)
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
98
99
100
101
|
# MIT License, Copyright (c) 2022 Marvin Borner
:import std/Combinator .
# true
true K
# false
false KI
# inverts boolean value
not [0 false true]
!( not
:test (!true) (false)
:test (!false) (true)
# true if both args are true
and [[1 0 false]]
(&&) and
:test (true && true) (true)
:test (true && false) (false)
:test (false && true) (false)
:test (false && false) (false)
# true if not both args are true
nand [[1 0 1 false true]]
:test (nand true true) (false)
:test (nand true false) (true)
:test (nand false true) (true)
:test (nand false false) (true)
# true if one of the args is true
or [[1 true 0]]
(||) or
:test (true || true) (true)
:test (true || false) (true)
:test (false || true) (true)
:test (false || false) (false)
# true if both args are false
nor [[1 1 0 false true]]
:test (nor true true) (false)
:test (nor true false) (false)
:test (nor false true) (false)
:test (nor false false) (true)
# true if args are not same bools
xor [[1 (not 0) 0]]
:test (xor true true) (false)
:test (xor true false) (true)
:test (xor false true) (true)
:test (xor false false) (false)
# true if both args are same bools
xnor [[1 0 (not 0)]]
:test (xnor true true) (true)
:test (xnor true false) (false)
:test (xnor false true) (false)
:test (xnor false false) (true)
# if first arg is true, exec first exp; else second exp
# this function is generally redundant
# I personally just write (exp? case-T case-F) directly
if [[[2 1 0]]]
(?!) if
:test (if true true false) (true)
:test ((true ?! true) false) (true)
:test (if false true false) (false)
:test ((false ?! true) false) (false)
# mathematical implies definition
implies [[or (not 1) 0]]
(=>?) implies
:test (true =>? true) (true)
:test (true =>? false) (false)
:test (false =>? true) (true)
:test (false =>? false) (true)
# mathematical iff (if and only if) definition
iff [[and (implies 1 0) (implies 0 1)]]
(<=>?) iff
:test (true <=>? true) (true)
:test (true <=>? false) (false)
:test (false <=>? true) (false)
:test (false <=>? false) (true)
|