Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!microsoft!uw-beaver!cornell!vax135!floyd!harpo!seismo!hao!hplabs!sri-unix!pereira From: pereira@sri-unix.UUCP Newsgroups: net.sources Subject: Prolog library: invoca.pl Message-ID: <104@sri-unix.UUCP> Date: Mon, 22-Aug-83 01:54:49 EDT Article-I.D.: sri-unix.104 Posted: Mon Aug 22 01:54:49 1983 Date-Received: Wed, 10-Aug-83 13:34:03 EDT Lines: 89 /* INVOCA.PL : Invocation routines UTILITY Lawrence Updated: 31 March 81 */ %%% Run this module interpreted %%% INVOCA requires no other modules &(A,B) :- !, A, B. \\(A,B) :- A, ! ; B, !. any([]) :- !, fail. any([L|Rest]) :- L. any([L|Rest]) :- !, any(Rest). binding(N,L) :- asserta('$bind'(N)), N > 0, L, retr(N2), N3 is N2-1, ( N3 =< 0 ; asserta('$bind'(N3)), fail ), !. binding(_,_,_) :- retr(_), fail. retr(N) :- retract('$bind'(N)), !. % Findall X's such that P. This is a funny version % which finds the FIRST solution that bagof would % find, but returns the empty list if there are no % solutions. (Logically dubious). findall(X,P,List) :- bagof(X,P,List), !. findall(X,P,[]). for(0,L) :- !. for(N,L) :- N > 0, L, N2 is N-1, for(N2,L), !. forall(A,C) :- A, not(C), !, fail. forall(_,_) :- !. nobt(X) :- X, !. not(X) :- X, !, fail. not(X) :- !. thnot(X) :- X, !, fail. thnot(X) :- !.