% -*-prolog-*- % represent a set as a list with no duplicate elements. % This code still has bugs. % union(+Set1, +Set2, -Result) Result is the union of sets % Set1 and Set2 union([], S2, S2). union([First | Rest], S2, U):- member(First, S2), union(Rest, S2, U). union([First | Rest], S2, [First | U]):- member(First, S2), union(Rest, S2, U). % member(Element, List) member(First, [First | _]). member(E, [_ | Rest]):- member(E, Rest].