I need help with the routine I'm trying to create. I need to make a routine that will look something like this:
difference([(a,b),(a,c),(b,c),(d,e)],[(a,_)],X).
X = [(b,c),(d,e)].
I really need help with this ...
I have written a method so far that can remove the first occurrence that it finds. However, I need to remove it from all occurrences. Here is what I still have ...
memberOf(A, [A|_]).
memberOf(A, [_|B]) :-
memberOf(A, B).
mapdiff([], _, []) :- !.
mapdiff([A|C], B, D) :-
memberOf(A, B), !,
mapdiff(C, B, D).
mapdiff([A|B], C, [A|D]) :-
mapdiff(B, C, D).
I took this code from the list (subtract).
I do not quite understand what he is doing, but I know that is almost what I want. I did not use subtraction, because my last code should be compatible with WIN-Prolog ... I am testing it on SWI Prolog.