In python's numpy
, one can swap values by index within a list easily like this:
a[[2, 3, 5]] = a[[5, 2, 3]]
Is there a good way to implement this function in Golang.
Go doesn't have fancy indexing like that; the closest you can do is
a[2],a[3],a[5] = a[5],a[2],a[3]
using regular indexing and regular tuple assignment.