diff --git a/pl/grammar.yap b/pl/grammar.yap index 3e61321ea..bf4bed709 100644 --- a/pl/grammar.yap +++ b/pl/grammar.yap @@ -138,7 +138,4 @@ phrase(Phrase, S0, S) :- '$t_body'(Phrase, _, last, S0, S, Goal), !, '$execute'(Goal). -lists:append([], L, L) . -lists:append([H|T], L, [H|R]) :- - lists:append(T, L, R). diff --git a/pl/init.yap b/pl/init.yap index b841125ea..be418237e 100644 --- a/pl/init.yap +++ b/pl/init.yap @@ -77,6 +77,29 @@ otherwise. :- dynamic prolog:'$user_defined_flag'/2. +lists:append([], L, L). +lists:append([H|T], L, [H|R]) :- + lists:append(T, L, R). + +% 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:memberchk(X,[X|_]) :- !. +lists:memberchk(X,[_|L]) :- + lists:memberchk(X,L). + +% 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:member(X,[X|_]) :- !. +lists:member(X,[_|L]) :- + lists:member(X,L). + + :- ['protect.yap']. version(yap,[5,1]). diff --git a/pl/modules.yap b/pl/modules.yap index 4f9573b26..02be0922a 100644 --- a/pl/modules.yap +++ b/pl/modules.yap @@ -469,25 +469,6 @@ current_module(Mod,TFN) :- source_module(Mod) :- '$current_module'(Mod). -% 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:memberchk(X,[X|_]) :- !. -lists:memberchk(X,[_|L]) :- - lists:memberchk(X,L). - -% 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:member(X,[X|_]) :- !. -lists:member(X,[_|L]) :- - lists:member(X,L). - - % comma has its own problems. :- '$install_meta_predicate'((:,:), prolog).