Files
kurious/pkg/utilities/slices/map.go
2023-11-23 19:13:54 +03:00

12 lines
191 B
Go

package slices
// Map slice from one type to another one.
func Map[S any, E any](s []S, f func(S) E) []E {
out := make([]E, len(s))
for i := range s {
out[i] = f(s[i])
}
return out
}