mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +00:00
11 lines
297 B
Go
11 lines
297 B
Go
package underscore
|
|
|
|
// Map produces a new slice of values by mapping each value in the slice through
|
|
// a transform function.
|
|
func Map[T, P any](values []T, transform func(T) P) []P {
|
|
res := make([]P, 0, len(values))
|
|
for _, v := range values {
|
|
res = append(res, transform(v))
|
|
}
|
|
return res
|
|
}
|