make sure list predicates are available to whoever needs them.
This commit is contained in:
parent
c7c4bd151c
commit
959e446218
26
pl/init.yap
26
pl/init.yap
@ -52,12 +52,9 @@ otherwise.
|
||||
|
||||
:- compile_expressions.
|
||||
|
||||
lists:append([], L, L).
|
||||
lists:append([H|T], L, [H|R]) :-
|
||||
lists:append(T, L, R).
|
||||
|
||||
|
||||
:- [
|
||||
% lists is often used.
|
||||
'lists.yap',
|
||||
'yio.yap',
|
||||
'debug.yap',
|
||||
'checker.yap',
|
||||
@ -71,6 +68,7 @@ lists:append([H|T], L, [H|R]) :-
|
||||
'modules.yap',
|
||||
% must follow grammar
|
||||
'eval.yap',
|
||||
'lists.yap',
|
||||
'signals.yap',
|
||||
'profile.yap',
|
||||
'callcount.yap',
|
||||
@ -95,24 +93,6 @@ lists:append([H|T], L, [H|R]) :-
|
||||
|
||||
:- source.
|
||||
|
||||
% memberchk(+Element, +Set)
|
||||
% means the same thing, but may only be used to test whether a known
|
||||
% Element occurs in a known Set. In return for this limited use, it
|
||||
% is more efficient when it is applicable.
|
||||
|
||||
lists:memberchk(X,[X|_]) :- !.
|
||||
lists:memberchk(X,[_|L]) :-
|
||||
lists:memberchk(X,L).
|
||||
|
||||
% member(?Element, ?Set)
|
||||
% is true when Set is a list, and Element occurs in it. It may be used
|
||||
% to test for an element or to enumerate all the elements by backtracking.
|
||||
% Indeed, it may be used to generate the Set!
|
||||
|
||||
lists:member(X,[X|_]).
|
||||
lists:member(X,[_|L]) :-
|
||||
lists:member(X,L).
|
||||
|
||||
:- no_source.
|
||||
|
||||
|
||||
|
24
pl/lists.yap
Normal file
24
pl/lists.yap
Normal file
@ -0,0 +1,24 @@
|
||||
% memberchk(+Element, +Set)
|
||||
% means the same thing, but may only be used to test whether a known
|
||||
% Element occurs in a known Set. In return for this limited use, it
|
||||
% is more efficient when it is applicable.
|
||||
|
||||
lists:memberchk(X,[X|_]) :- !.
|
||||
lists:memberchk(X,[_|L]) :-
|
||||
lists:memberchk(X,L).
|
||||
|
||||
% member(?Element, ?Set)
|
||||
% is true when Set is a list, and Element occurs in it. It may be used
|
||||
% to test for an element or to enumerate all the elements by backtracking.
|
||||
% Indeed, it may be used to generate the Set!
|
||||
|
||||
lists:member(X,[X|_]).
|
||||
lists:member(X,[_|L]) :-
|
||||
lists:member(X,L).
|
||||
|
||||
lists:append([], L, L).
|
||||
lists:append([H|T], L, [H|R]) :-
|
||||
lists:append(T, L, R).
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user