swapElements = [
origList = $arg1
swap1 = $arg2
swap2 = $arg3
newList = []
loop sel (listlen $origList) [
if (= $sel $swap1) [
add2list newList (at $origList $swap2)
] [
if (= $sel $swap2) [
add2list newList (at $origList $swap1)
] [
add2list newList (at $origList $sel)
]
]
]
result $newList
]