reverse added

This commit is contained in:
Timon Ringwald 2022-08-21 13:52:53 +02:00
parent f7ab541d0a
commit fc31b733b4

10
reverse.go Normal file
View 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
}