ord_intersection/4

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@352 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2002-02-08 22:35:04 +00:00
parent 1f5af38ba8
commit 90356f9993
1 changed files with 21 additions and 0 deletions

View File

@ -28,6 +28,7 @@
ord_intersect/2, % Set x Set ->
ord_intersect/3, % Set x Set -> Set
ord_intersection/3, % Set x Set -> Set
ord_intersection/4, % Set x Set -> Set x Set
ord_seteq/2, % Set x Set ->
ord_setproduct/3, % Set x Set -> Set
ord_subset/2, % Set x Set ->
@ -170,6 +171,26 @@ ord_intersection(>, Head1, Tail1, _, Tail2, Intersection) :-
% ord_intersection(+Set1, +Set2, ?Intersection, ?Difference)
% is true when Intersection is the ordered representation of Set1
% and Set2, provided that Set1 and Set2 are ordered sets.
ord_intersection(L, [], [], L) :- !.
ord_intersection([], L, [], L) :- !.
ord_intersection([Head1|Tail1], [Head2|Tail2], Intersection, Difference) :-
compare(Order, Head1, Head2),
ord_intersection(Order, Head1, Tail1, Head2, Tail2, Intersection, Difference).
ord_intersection(=, Head, Tail1, _, Tail2, [Head|Intersection], Difference) :-
ord_intersection(Tail1, Tail2, Intersection, Difference).
ord_intersection(<, Head1, Tail1, Head2, Tail2, Intersection, [Head1|Difference]) :-
ord_intersection(Tail1, [Head2|Tail2], Intersection, Difference).
ord_intersection(>, Head1, Tail1, Head2, Tail2, Intersection, [Head2|Difference]) :-
ord_intersection([Head1|Tail1], Tail2, Intersection, Difference).
% ord_seteq(+Set1, +Set2)
% is true when the two arguments represent the same set. Since they
% are assumed to be ordered representations, they must be identical.