1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-11-27 22:28:29 +02:00
Files
fp-go/eq/contramap.go

12 lines
267 B
Go
Raw Normal View History

package eq
// Contramap implements an Equals predicate based on a mapping
func Contramap[A, B any](f func(b B) A) func(Eq[A]) Eq[B] {
return func(fa Eq[A]) Eq[B] {
equals := fa.Equals
return FromEquals(func(x, y B) bool {
return equals(f(x), f(y))
})
}
}