1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-06-23 00:27:49 +02:00
Files
fp-go/predicate/bool.go
Dr. Carsten Leue c07df5c771 initial checkin
Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
2023-07-07 22:31:06 +02:00

26 lines
631 B
Go

package predicate
func Not[A any](predicate func(A) bool) func(A) bool {
return func(a A) bool {
return !predicate((a))
}
}
// And creates a predicate that combines other predicates via &&
func And[A any](second func(A) bool) func(func(A) bool) func(A) bool {
return func(first func(A) bool) func(A) bool {
return func(a A) bool {
return first(a) && second(a)
}
}
}
// Or creates a predicate that combines other predicates via ||
func Or[A any](second func(A) bool) func(func(A) bool) func(A) bool {
return func(first func(A) bool) func(A) bool {
return func(a A) bool {
return first(a) || second(a)
}
}
}