10 lines
178 B
Go
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
|
||
|
}
|