Initial commit of modash

This was taken from github.com/lmika/gopkgs/fp
This commit is contained in:
Leon Mika 2025-01-27 13:19:52 +11:00
commit a20530ddfd
20 changed files with 425 additions and 0 deletions

17
momap/values.go Normal file
View file

@ -0,0 +1,17 @@
package momap
func Values[K comparable, V any](m map[K]V) []V {
vs := make([]V, 0, len(m))
for _, v := range m {
vs = append(vs, v)
}
return vs
}
func MapValues[K comparable, V any, W any](m map[K]V, fn func(v V, k K) W) map[K]W {
ws := make(map[K]W)
for k, v := range m {
ws[k] = fn(v, k)
}
return ws
}