v8.run/go/exp@v0.0.26-0.20230226010534-afcdbd3f782d/util/slice/map.go (about) 1 package slice 2 3 func Map[T, R any](p []T, fn func(v T, i int) R) []R { 4 o := make([]R, len(p)) 5 for i, v := range p { 6 o[i] = fn(v, i) 7 } 8 return o 9 }