14 lines
220 B
Go
14 lines
220 B
Go
package utils
|
|
|
|
type Mapper[T, R any] func(T) R
|
|
|
|
func MapSlice[T, R any](input []T, mapper Mapper[T, R]) []R {
|
|
output := make([]R, len(input))
|
|
|
|
for i := range input {
|
|
output[i] = mapper(input[i])
|
|
}
|
|
|
|
return output
|
|
}
|