Add functional predicate XNOR (#181)

Add new function, Xnor, designed to create a composed predicate representing
the logical Exclusive NOR (XNOR) operation applied to a list of predicates.
The XNOR operation is a logical operation that returns true only
if all operands have the same boolean value
This commit is contained in:
donutloop authored and GitHub committed 2024-02-25 20:24:47 +08:00
1 parent aebab7c944
commit a43bc554ee
3 files changed
+62

No files matched your search

+16
View File
@@ -73,6 +73,22 @@ func ExampleNor() {
// false
}
func ExampleXnor() {
isEven := func(i int) bool { return i%2 == 0 }
isPositive := func(i int) bool { return i > 0 }
match := Xnor(isEven, isPositive)
fmt.Println(match(2))
fmt.Println(match(-3))
fmt.Println(match(3))
// Output:
// true
// true
// false
}
// func ExamplePredicatesMix() {
// a := Or(
// func(s string) bool { return strings.ContainsAny(s, "0123456789") },