add subtract/3 to lists.
This commit is contained in:
parent
a9587b5e3d
commit
5c54ff89a1
14
docs/yap.tex
14
docs/yap.tex
@ -1,4 +1,4 @@
|
|||||||
<EFBFBD>a\input texinfo @c -*- mode: texinfo; coding: latin-1; -*-
|
\input texinfo @c -*- mode: texinfo; coding: latin-1; -*-
|
||||||
|
|
||||||
@c %**start of header
|
@c %**start of header
|
||||||
@setfilename yap.info
|
@setfilename yap.info
|
||||||
@ -9242,6 +9242,18 @@ Succeeds if @var{Set3} unifies with the intersection of @var{Set1} and
|
|||||||
need not be ordered.
|
need not be ordered.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@item subtract(+@var{Set}, +@var{Delete}, ?@var{Result})
|
||||||
|
@findex subtract/3
|
||||||
|
@syindex subtract/3
|
||||||
|
@cnindex subtract/3
|
||||||
|
Delete all elements from @var{Set} that occur in @var{Delete} (a set)
|
||||||
|
and unify the result with @var{Result}. Deletion is based on
|
||||||
|
unification using @code{memberchk/2}. The complexity is
|
||||||
|
@code{|Delete|*|Set|}.
|
||||||
|
|
||||||
|
See @code{ord_subtract/3}.
|
||||||
|
@end table
|
||||||
|
|
||||||
@node LineUtilities, MapList, Lists, Library
|
@node LineUtilities, MapList, Lists, Library
|
||||||
@section Line Manipulation Utilities
|
@section Line Manipulation Utilities
|
||||||
@cindex Line Utilities Library
|
@cindex Line Utilities Library
|
||||||
|
@ -8,9 +8,14 @@
|
|||||||
append/3,
|
append/3,
|
||||||
append/2,
|
append/2,
|
||||||
delete/3,
|
delete/3,
|
||||||
|
intersection/3,
|
||||||
|
flatten/2,
|
||||||
last/2,
|
last/2,
|
||||||
|
list_concat/2,
|
||||||
|
max_list/2,
|
||||||
member/2,
|
member/2,
|
||||||
memberchk/2,
|
memberchk/2,
|
||||||
|
min_list/2,
|
||||||
nextto/3,
|
nextto/3,
|
||||||
nth/3,
|
nth/3,
|
||||||
nth/4,
|
nth/4,
|
||||||
@ -18,6 +23,7 @@
|
|||||||
nth0/4,
|
nth0/4,
|
||||||
nth1/3,
|
nth1/3,
|
||||||
nth1/4,
|
nth1/4,
|
||||||
|
numlist/3,
|
||||||
permutation/2,
|
permutation/2,
|
||||||
prefix/2,
|
prefix/2,
|
||||||
remove_duplicates/2,
|
remove_duplicates/2,
|
||||||
@ -27,16 +33,11 @@
|
|||||||
selectchk/3,
|
selectchk/3,
|
||||||
sublist/2,
|
sublist/2,
|
||||||
substitute/4,
|
substitute/4,
|
||||||
|
subtract/3,
|
||||||
|
suffix/2,
|
||||||
sum_list/2,
|
sum_list/2,
|
||||||
sum_list/3,
|
sum_list/3,
|
||||||
suffix/2,
|
sumlist/2
|
||||||
sumlist/2,
|
|
||||||
list_concat/2,
|
|
||||||
flatten/2,
|
|
||||||
max_list/2,
|
|
||||||
min_list/2,
|
|
||||||
numlist/3,
|
|
||||||
intersection/3
|
|
||||||
]).
|
]).
|
||||||
|
|
||||||
:- use_module(library(error),
|
:- use_module(library(error),
|
||||||
@ -400,3 +401,17 @@ intersection([X|T], L, Intersect) :-
|
|||||||
intersection([_|T], L, R) :-
|
intersection([_|T], L, R) :-
|
||||||
intersection(T, L, R).
|
intersection(T, L, R).
|
||||||
|
|
||||||
|
%% subtract(+Set, +Delete, -Result) is det.
|
||||||
|
%
|
||||||
|
% Delete all elements from `Set' that occur in `Delete' (a set)
|
||||||
|
% and unify the result with `Result'. Deletion is based on
|
||||||
|
% unification using memberchk/2. The complexity is |Delete|*|Set|.
|
||||||
|
%
|
||||||
|
% @see ord_subtract/3.
|
||||||
|
|
||||||
|
subtract([], _, []) :- !.
|
||||||
|
subtract([E|T], D, R) :-
|
||||||
|
memberchk(E, D), !,
|
||||||
|
subtract(T, D, R).
|
||||||
|
subtract([H|T], D, [H|R]) :-
|
||||||
|
subtract(T, D, R).
|
||||||
|
Reference in New Issue
Block a user