Hi,
A declarative builder/3 could be defined as follows:
builder(X,G,L) :-
forall(member(X,L),G),
forall(G,member(X,L)).
But I guess this is not very helpful.
But you could use it to verify that a findall
result is correct, modulo duplicates and
reordering. For example you can do:
Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.10)
p(a).
p(b).
p(c).
?- builder(X,p(X),[a,b,c]).
true
?- builder(X,p(X),[a,b]).
false
?- builder(X,p(X),[a,b,c,d]).
false
Bye
P.S.: forall/3 is defined as follows and preloaded
standard in SWI-Prolog.
forall(C,A) :- \+ (C, \+ A).
P.P.S.: The builder shows that it as both positive
and negative polarity. Means inserts in the goal G
change the result, and deletes in the goal G change
the result.
Ha Ha
P.P.S.: More ideas:
https://stackoverflow.com/questions/7647758/prolog-findall-implementation
Mark Tarver schrieb:
> Can findall be implemented in Prologitself - not using asserta or assertzbut only a declarative Prolog with at