Unfortunately I run out of ideas on how to solve the problem of searching and removing elements in a variable size list. Below you can find an example.
the condition to remove the element of the list is given by the following procedure.
T1 := table([2=3,3=2,5=6,6=5,7=9,9=7]):
T2 := table([2=3,3=2]):
if it is a member, the element indexed by k should be removed from abc and then the search continues using the next element in abc (that now has one less element). Otherwise, the element is kept and the search moves to next one. The process ends when the last element in a short version of abc is tested.
Thanks all for the help and patience.