Linklist.swap
From OpenEUO
Calling Pattern
Call
local k = sl.linklist() -- later local r,s = k.swap(a,b)
Arguments
a is a number b is a number
Results
r is a number s is a number
Example Usage
local k = sl.linklist() local j = k.inserta(0,'one') local j0 = j j = k.inserta(j,'two') j = k.inserta(j,'three') k.swap(j0,j) print(k.value(k.head()))
--> three
Description
Calling swap reverses the values associated with valid link pseudo-indices a and b. For all successful calls, swap returns the tuple b,a. If the list is empty or a (or b) is otherwise an invalid pseudo-index, swap returns 0.