11 lines
173 B
Go
11 lines
173 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] = s[i]
|
||
|
}
|
||
|
return s
|
||
|
}
|