1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-11-25 22:21:49 +02:00
Files
fp-go/record/generic/eq.go
Dr. Carsten Leue b25de3c7c3 doc: fix case
Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
2023-07-18 15:57:54 +02:00

25 lines
470 B
Go

package generic
import (
E "github.com/IBM/fp-go/eq"
)
func equals[M ~map[K]V, K comparable, V any](left, right M, eq func(V, V) bool) bool {
if len(left) != len(right) {
return false
}
for k, v1 := range left {
if v2, ok := right[k]; !ok || !eq(v1, v2) {
return false
}
}
return true
}
func Eq[M ~map[K]V, K comparable, V any](e E.Eq[V]) E.Eq[M] {
eq := e.Equals
return E.FromEquals(func(left, right M) bool {
return equals(left, right, eq)
})
}