Swap Function?
Recently, I noticed that Cyphre implemented a swap function for series of graphics objects. The purpose was to quickly swap two values within a series (or between two series).
The idea of adding swap as a native function to REBOL has been suggested before (many years). Here is an example of what it would do:
Given:
v1: at series1 10
v2: at series2 20
would you prefer to do:
tmp: first v1
change/only v1 first v2
change/only v2 tmp
or:
swap v1 v2
The function would also work within the same series.
A /part refinement could allow swapping of multiple values.
Question: should such a function be provided (at the native level it could be highly optimized compared to the above change code)? Is it really that useful for string series (seems like it would rarely get used) or just blocks?
13 Comments
|