minireader/internal/pkg/utils/slices.go
2024-08-10 11:01:50 +07:00

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
}