fix lists predicates
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2141 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
c07c5286c0
commit
fda34985b9
@ -138,7 +138,4 @@ phrase(Phrase, S0, S) :-
|
|||||||
'$t_body'(Phrase, _, last, S0, S, Goal), !,
|
'$t_body'(Phrase, _, last, S0, S, Goal), !,
|
||||||
'$execute'(Goal).
|
'$execute'(Goal).
|
||||||
|
|
||||||
lists:append([], L, L) .
|
|
||||||
lists:append([H|T], L, [H|R]) :-
|
|
||||||
lists:append(T, L, R).
|
|
||||||
|
|
||||||
|
23
pl/init.yap
23
pl/init.yap
@ -77,6 +77,29 @@ otherwise.
|
|||||||
:- dynamic prolog:'$user_defined_flag'/2.
|
:- 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'].
|
:- ['protect.yap'].
|
||||||
|
|
||||||
version(yap,[5,1]).
|
version(yap,[5,1]).
|
||||||
|
@ -469,25 +469,6 @@ current_module(Mod,TFN) :-
|
|||||||
source_module(Mod) :-
|
source_module(Mod) :-
|
||||||
'$current_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.
|
% comma has its own problems.
|
||||||
:- '$install_meta_predicate'((:,:), prolog).
|
:- '$install_meta_predicate'((:,:), prolog).
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user