Prolog adding and removing list element if non present in second list
- by logically
I don't know what I'm missing here.
I wan't to add an element if it is in arg1 but not in arg2 and want to remove an element if it is in arg1 but not in arg2.
I'm using an if condition with includes function that return true if the element is in the arg2 list, false otherwise. Then use built it predicates append and select to add or remove.
I'm getting false to all my objectives searches. I comment and uncomment depending on what predicate I want, add or remove.
includes([],_).
includes([P|Z],S) :- memberchk(P,S), includes(Z,S).
addop([],list,res).
addop([P|R],list,res) :- includes(P,s0) - addop(R,list,res) ; append(P,list,res), addop(R,list,res).
rem([],list,res).
rem([P|R],list,res) :- includes(P,list) - rem(R,list,res) ; select(P,list,res),rem(R,list,res).
Thanks for help.