:- lib(to_functor/2). :- lib(stoics_lib:en_list/2). /** options_remove( +Options, +Remove, -Clean ). Clean contains only Option(s) that have non mathcing Remove. Remove can be a single name / arity term or other compound term, or a list of either two terms. The other compound version allows for passing through default lists. == ?- options_remove( [abc(d),def(g)], def(t), Clean ). Clean = [abc(d)]. ?- options_remove( [abc(d),def(g)], [def/1], Clean ). Clean = [abc(d)]. == */ options_remove( OptsIn, RmvIn, Clean ) :- en_list( RmvIn, RmvList ), maplist( to_functor, RmvList, Remove ), en_list( OptsIn, Opts ), options_functors_remove( Opts, Remove, Clean ). options_functors_remove( [], _Functors, [] ). options_functors_remove( [O|Os], Functors, Opts ) :- functor( O, Name, Arity ), ( memberchk(Name/Arity,Functors) -> TOpts = Opts ; Opts = [O|TOpts] ), options_functors_remove( Os, Functors, TOpts ).