intersection/3
This commit is contained in:
parent
2566ebcee5
commit
b0b42d0e31
@ -4149,7 +4149,7 @@ The following predicates provide counting:
|
|||||||
@cnindex plus/3
|
@cnindex plus/3
|
||||||
True if @var{Int3} = @var{Int1} + @var{Int2}. At least two of the
|
True if @var{Int3} = @var{Int1} + @var{Int2}. At least two of the
|
||||||
three arguments must be instantiated to integers.
|
three arguments must be instantiated to integers.
|
||||||
|
@end table
|
||||||
|
|
||||||
@node I/O, Database, Arithmetic, Top
|
@node I/O, Database, Arithmetic, Top
|
||||||
@section I/O Predicates
|
@section I/O Predicates
|
||||||
@ -9006,6 +9006,13 @@ If @var{Low} and @var{High} are integers with @var{Low} =<
|
|||||||
@var{High}, unify @var{List} to a list @code{[Low, Low+1, ...High]}. See
|
@var{High}, unify @var{List} to a list @code{[Low, Low+1, ...High]}. See
|
||||||
also @code{between/3}.
|
also @code{between/3}.
|
||||||
|
|
||||||
|
@item intersection(+@var{Set1}, +@var{Set2}, +@var{Set3})
|
||||||
|
@findex intersection/3
|
||||||
|
@syindex intersection/3
|
||||||
|
@cnindex intersection/3
|
||||||
|
Succeeds if @var{Set3} unifies with the intersection of @var{Set1} and
|
||||||
|
@var{Set2}. @var{Set1} and @var{Set2} are lists without duplicates. They
|
||||||
|
need not be ordered.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@node LineUtilities, MapList, Lists, Library
|
@node LineUtilities, MapList, Lists, Library
|
||||||
|
@ -35,7 +35,8 @@
|
|||||||
flatten/2,
|
flatten/2,
|
||||||
max_list/2,
|
max_list/2,
|
||||||
min_list/2,
|
min_list/2,
|
||||||
numlist/3
|
numlist/3,
|
||||||
|
intersection/3
|
||||||
]).
|
]).
|
||||||
|
|
||||||
:- use_module(library(error),
|
:- use_module(library(error),
|
||||||
@ -390,3 +391,12 @@ numlist_(L, U, [L|Ns]) :-
|
|||||||
numlist_(L2, U, 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).
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user