News flash: I'm going to Australia in February, so this Web site may be switched off at any time.
We have seen how the ``push()
'' and ``pop()
''
function aid in
using Icon lists as stacks.
Two more functions allow elements to be added and removed from the
end of any list:
put(L, x)
'' adds x after
the old last element of list L.
pull(L)
'' removes the last element from
list L and returns the value removed.
To sum up, here is a picture of how the four stack and queue functions in Icon work:
push --> +--------+--------+-------+--------+ <-- put | L[1] | L[2] | ... | L[*L] | pop <-- +--------+--------+-------+--------+ --> pull
john@nmt.edu