mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-08 06:32:28 +08:00
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:
@@ -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") },
|
||||
|
||||
Reference in New Issue
Block a user