Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- setIntersection([], [], []).
- setIntersection([], _, []).
- setIntersection([X|Xs], Y, [Z|W]) :-
- keepDuplicates(X, Y, [Z|Zs]),
- setIntersection(Xs, Y, W).
- keepDuplicates(_, [], []).
- keepDuplicates([], _, []).
- keepDuplicates([], [], []).
- % Check if the head of the first list is not a match to the
- % first head of the second list
- keepDuplicates(G, [H|Hs], Line) :-
- G = H,
- keepDuplicates(G, Hs, Line).
- % Check if the head of the first list
- % Does match to the head of the second list
- keepDuplicates(G, [G|Gs], [G|NewLine]) :-
- keepDuplicates(G, Gs, NewLine).
- ?- L1=[3,4,5,6],L2=[5,1,0,2,4],findall(C, (member(C,L1),memberchk(C,L2)), I).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement