VarSwap
Swaps two elements in a linear container variable.
Syntax
-
VarSwap(X, i, j)
-
X
is a variable that is a linear container -
i
andj
are integers
-
If X
is an lvalue and a container and i
and j
are valid indices in X
, then VarSwap(X, i, j)
swaps the elements with indices i
and j
and returns success
.
This is the procedural version of swap
.
Examples
v ≔ SequenceVector(10)
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
VarSwap(v, 1, −1)
success
v
(10, 2, 3, 4, 5, 6, 7, 8, 9, 1)