pereira@sri-unix.UUCP (08/15/83)
/* LISTRO.PL : List manipulating routines UTILITY Lawrence Updated: 31 March 81 */ %%% Compile this module %%% LISTRO requires module: SETROU /* EXPORT */ :- public append/3, disjoint/1, last/2, listtoset/2, nextto/3, numlist/3, perm/2, perm2/4, remove_dups/2, rev/2, select/3, sumlist/2, pairfrom/4. /* MODES */ :- mode append(?,?,?). :- mode disjoint(?). :- mode last(?,?). :- mode listtoset(?,?). :- mode nextto(?,?,?). :- mode numlist(+,+,?). :- mode perm(?,?). :- mode perm2(?,?,?,?). :- mode remove_dups(?,?). :- mode rev(?,?). :- mode revconc(?,+,?). :- mode select(?,?,?). :- mode sumlist(+,?). :- mode pairfrom(+,?,?,?). append([],L,L). append([HD|TL],L,[HD|LL]) :- append(TL,L,LL). disjoint([]). disjoint([HD|TL]) :- memberchk(HD,TL), !,862 From: sri-unix!pereira Newsgroups: net.sources Title: Prolog library: imisce.pl Article-I.D.: sri-unix.100 Posted: Mon Aug 8 22:53:02 1983 /* IMISCE.PL : Miscellaneous routines (interpreted) UTILITY Lawrence Updated: 30 March 81 */ %%% Run this module interpreted %%% IMISCE requires no other modules continue. \=(X,X) :- !, fail. \=(X,Y) :- !. casserta(X) :- X, !. casserta(X) :- !, asserta(X). cassertz(X) :- X, !. cassertz(X) :- !, assertz(X). clean :- nolog, seeing(X), see('prolog.log'), rename('prolog.log',[]), seen, see(X), log. diff(X,X) :- !, fail. diff(X,Y) :- !. gcc(X) :- nobt(X), asserta('$gcc'(X)), fail. gcc(X) :- retract('$gcc'(Y)), !, X = Y. subgoal(exact,L) :- numbervars(L,1,N), ( subgoal_of(L) -> fail ; !, fail ). subgoal(exact,L). Sum, !. % Get a pair of elements from a list, also % return the rest. Pairs are only returned % once (not twice different ways round) pairfrom([X|T],X,Y,R) :- select(Y,T,R). pairfrom([H|S],X,Y,[H|T]) :- pairfrom(S,X,Y,T).