intersection/3

This commit is contained in:
Vítor Santos Costa II
2010-04-21 00:15:11 +01:00
parent 2566ebcee5
commit b0b42d0e31
2 changed files with 19 additions and 2 deletions

View File

@@ -35,7 +35,8 @@
flatten/2,
max_list/2,
min_list/2,
numlist/3
numlist/3,
intersection/3
]).
:- use_module(library(error),
@@ -390,3 +391,12 @@ numlist_(L, U, [L|Ns]) :-
numlist_(L2, U, Ns).
% copied from SWI lists library.
intersection([], _, []) :- !.
intersection([X|T], L, Intersect) :-
memberchk(X, L), !,
Intersect = [X|R],
intersection(T, L, R).
intersection([_|T], L, R) :-
intersection(T, L, R).