Initial commit of modash
This was taken from github.com/lmika/gopkgs/fp
This commit is contained in:
commit
a20530ddfd
20 changed files with 425 additions and 0 deletions
17
momap/values.go
Normal file
17
momap/values.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue