clear := proc (f::procedure, S::{list, set, {identical(keep),identical(delete)}={list,set}}) local T, Tin, R, j, G, fnew, exc; options `Maple Advisor Database 1.00 for Maple V Release 4 and 5`, `Copyright (c) 1997 by Robert B. Israel. All rights reserved`; if type(S, equation) then exc:= evalb(lhs(S)='delete'); R:= rhs(S) else exc:= false; R:= S; fi; if type(R,set(list)) then NULL elif type(R,list(list)) then R := {op(R)} elif type(R,set) then R := map(t -> [t],R) else R := map(t -> [t],{op(R)}) fi; G := op(3,eval(f)); T := op(4,eval(f)); if T = NULL then Tin:= {} else Tin:= {indices(T)} fi; fnew := subsop(3 = (G,'foo'), 4 = NULL,eval(f)); if exc then R:= Tin minus R else R:= Tin intersect R fi; for j in R do fnew(op(j)) := T[op(j)] od; subsop(3=G,eval(fnew)); end;