11 lines
177 B
Go
11 lines
177 B
Go
package slices
|
|
|
|
func Reverse[T any](slice []T) []T {
|
|
s := make([]T, len(slice))
|
|
for i := 0; i < len(slice); i++ {
|
|
ri := len(slice) - 1 - i
|
|
s[ri] = slice[i]
|
|
}
|
|
return s
|
|
}
|