To interchange the values of two variables
X and
Y, we can write
W = Y; Y = X; X = W
In Rexx we can exchange words X and Y by statement
parse value X Y with Y X
Another (general) way is using of the VALUE function. The VALUE function returns the value of the symbol named by the first argument and optionally assigns it a new value.
X = VALUE('Y', X)
And the values of sequence X, Y, Z can be rearranged to Z, X, Y
(ie. the new value of Y is to be the original value of X, etc.) by the fragment
W = Z; Z = Y; Y = X; X = W
A general solution of this problem, for I-variables A.1,A.2,...,A.I (I>=2), follows