mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 14:59:41 +02:00
10 lines
256 B
Go
10 lines
256 B
Go
package slices
|
|
|
|
// Map applies the given function to each element of the slice and returns a new slice with the results
|
|
func Map[T, U any](s []T, f func(T) U) []U {
|
|
result := make([]U, len(s))
|
|
for i, v := range s {
|
|
result[i] = f(v)
|
|
}
|
|
return result
|
|
}
|