Content-Length: 278322 | pFad | https://github.com/go-python/gpython/commit/194e817c2c2bb6c33109b7ad993bec9f583e8ae5

2E py: tuple - Reverse method · go-python/gpython@194e817 · GitHub
Skip to content

Commit 194e817

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

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

py/tuple.go

Lines changed: 8 additions & 0 deletions
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/go-python/gpython/commit/194e817c2c2bb6c33109b7ad993bec9f583e8ae5

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy