Skip to content

Commit 194e817

Browse files
committed
py: tuple - Reverse method
1 parent 3a897b0 commit 194e817

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

py/tuple.go

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ func (t Tuple) Copy() Tuple {
2727
copy(newT, t)
2828
return newT
2929
}
30+
31+
// Reverses a tuple (in-place)
32+
func (t Tuple) Reverse() {
33+
for i, j := 0, len(t)-1; i < j; i, j = i+1, j-1 {
34+
t[i], t[j] = t[j], t[i]
35+
}
36+
}
37+
3038
func (t Tuple) M__len__() Object {
3139
return Int(len(t))
3240
}

0 commit comments

Comments
 (0)