slices/map.go
2022-09-06 01:58:19 +02:00

10 lines
178 B
Go

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
}