* Generated files
[chr.git] / find.pl
blob5fc2e447234349ce315ff19b178e808375cae147
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 % Author: Bart Demoen, Tom Schrijvers
3 % Email: Bart.Demoen@cs.kuleuven.ac.be, Tom.Schrijvers@cs.kuleuven.ac.be
4 % Copyright: K.U.Leuven 2004
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 :- module(find,
9 find_with_var_identity/4,
10 forall/3,
11 forsome/3
12 ]).
14 :- use_module(library(lists)).
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16 find_with_var_identity(Template, IdVars, Goal, Answers) :-
17 Key = foo(IdVars),
18 findall(Key - Template, Goal, As),
19 smash(As,Key,Answers).
21 smash([],_,[]).
22 smash([Key-T|R],Key,[T|NR]) :- smash(R,Key,NR).
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25 forall(X,L,G) :-
26 \+ (member(X,L), \+ call(G)).
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29 forsome(X,L,G) :-
30 once((
31 member(X,L),
32 call(G)
33 )).