more helper functions

This commit is contained in:
Timon Ringwald
2022-09-06 01:58:19 +02:00
parent 4f3cf3f537
commit cdb1cf3e03
6 changed files with 87 additions and 18 deletions

9
map.go Normal file
View File

@ -0,0 +1,9 @@
package slices
func Map[I, O any](slice []I, mapper func(I) O) []O {
ret := make([]O, 0, len(slice))
for _, v := range slice {
ret = append(ret, mapper(v))
}
return ret
}