Swap() Function
This function takes input in the form of swap(<list>, <element 1>, <element 2>[, <delimiter>]) and returns the <list> with the elements in the numeric positions <element 1> and <element 2> swapped.
Instructions
Copy and paste the below code into a compatible MUSH or MUX.
MUSHCode for Swap() Function
@@ This function takes input in the form of swap(<list>, <element 1>, <element 2>[, <delimiter>])
@@ and returns the <list> with the elements in the numeric positions <element 1> and <element 2>
@@ swapped. A delimiter may be specified. If it is omited, the list is assumed to be space-separated.
@@ If either element is out of range, swap() returns the list with the other element removed. If
@@ both elements are out of range, the list is returned unaltered.
[iter(%0,switch(#@,%1,elements(%0,%2,%3),%2,elements(%0,%1,%3),##),%3,[switch('%4','',%b,%4)])]
@@ Swap code by Telgar@M*U*S*H
@@ and returns the <list> with the elements in the numeric positions <element 1> and <element 2>
@@ swapped. A delimiter may be specified. If it is omited, the list is assumed to be space-separated.
@@ If either element is out of range, swap() returns the list with the other element removed. If
@@ both elements are out of range, the list is returned unaltered.
[iter(%0,switch(#@,%1,elements(%0,%2,%3),%2,elements(%0,%1,%3),##),%3,[switch('%4','',%b,%4)])]
@@ Swap code by Telgar@M*U*S*H