Add functional predicate NAND (#182)

Add new function, NAND, designed to create a composed predicate representing the logical NAND operation
applied to a list of predicates. The NAND operation is a logical operation
that returns true only if all perdicate result in false otherwise false
This commit is contained in:
donutloop authored and GitHub committed 2024-02-26 09:58:19 +08:00
1 parent a43bc554ee
commit 805e2543d0
3 files changed
+54 -4

No files matched your search

+16
View File
@@ -53,6 +53,22 @@ func ExampleAnd() {
// false
}
func ExampleNand() {
isNumericAndLength5 := Nand(
func(s string) bool { return strings.ContainsAny(s, "0123456789") },
func(s string) bool { return len(s) == 5 },
)
fmt.Println(isNumericAndLength5("12345"))
fmt.Println(isNumericAndLength5("1234"))
fmt.Println(isNumericAndLength5("abcdef"))
// Output:
// false
// false
// true
}
func ExampleNor() {
match := Nor(
func(s string) bool { return strings.ContainsAny(s, "0123456789") },