reverse added
This commit is contained in:
parent
f7ab541d0a
commit
fc31b733b4
10
reverse.go
Normal file
10
reverse.go
Normal file
@ -0,0 +1,10 @@
|
||||
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
|
||||
}
|
Loading…
Reference in New Issue
Block a user