summaryrefslogtreecommitdiff
path: root/vendor/github.com/dalzilio/rudd/operator.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-22 17:35:49 -0600
committermo khan <mo@mokhan.ca>2025-07-22 17:35:49 -0600
commit20ef0d92694465ac86b550df139e8366a0a2b4fa (patch)
tree3f14589e1ce6eb9306a3af31c3a1f9e1af5ed637 /vendor/github.com/dalzilio/rudd/operator.go
parent44e0d272c040cdc53a98b9f1dc58ae7da67752e6 (diff)
feat: connect to spicedb
Diffstat (limited to 'vendor/github.com/dalzilio/rudd/operator.go')
-rw-r--r--vendor/github.com/dalzilio/rudd/operator.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/vendor/github.com/dalzilio/rudd/operator.go b/vendor/github.com/dalzilio/rudd/operator.go
new file mode 100644
index 0000000..55a5627
--- /dev/null
+++ b/vendor/github.com/dalzilio/rudd/operator.go
@@ -0,0 +1,57 @@
+// Copyright (c) 2021 Silvano DAL ZILIO
+//
+// MIT License
+
+package rudd
+
+// Operator describe the potential (binary) operations available on an Apply.
+// Only the first four operators (from OPand to OPnand) can be used in AppEx.
+type Operator int
+
+const (
+ OPand Operator = iota
+ OPxor
+ OPor
+ OPnand
+ OPnor
+ OPimp
+ OPbiimp
+ OPdiff
+ OPless
+ OPinvimp
+ // opnot, for negation, is the only unary operation. It should not be used
+ // in Apply
+ opnot
+)
+
+var opnames = [12]string{
+ OPand: "and",
+ OPxor: "xor",
+ OPor: "or",
+ OPnand: "nand",
+ OPnor: "nor",
+ OPimp: "imp",
+ OPbiimp: "biimp",
+ OPdiff: "diff",
+ OPless: "less",
+ OPinvimp: "invimp",
+ opnot: "not",
+}
+
+func (op Operator) String() string {
+ return opnames[op]
+}
+
+var opres = [12][2][2]int{
+ // 00 01 10 11
+ OPand: {0: [2]int{0: 0, 1: 0}, 1: [2]int{0: 0, 1: 1}}, // 0001
+ OPxor: {0: [2]int{0: 0, 1: 1}, 1: [2]int{0: 1, 1: 0}}, // 0110
+ OPor: {0: [2]int{0: 0, 1: 1}, 1: [2]int{0: 1, 1: 1}}, // 0111
+ OPnand: {0: [2]int{0: 1, 1: 1}, 1: [2]int{0: 1, 1: 0}}, // 1110
+ OPnor: {0: [2]int{0: 1, 1: 0}, 1: [2]int{0: 0, 1: 0}}, // 1000
+ OPimp: {0: [2]int{0: 1, 1: 1}, 1: [2]int{0: 0, 1: 1}}, // 1101
+ OPbiimp: {0: [2]int{0: 1, 1: 0}, 1: [2]int{0: 0, 1: 1}}, // 1001
+ OPdiff: {0: [2]int{0: 0, 1: 0}, 1: [2]int{0: 1, 1: 0}}, // 0010
+ OPless: {0: [2]int{0: 0, 1: 1}, 1: [2]int{0: 0, 1: 0}}, // 0100
+ OPinvimp: {0: [2]int{0: 1, 1: 0}, 1: [2]int{0: 1, 1: 1}}, // 1011
+}