builds a list of all arguments that cause a goal to succeed
INCLUDE 'prolib.h' findall(X,goal(X,args),L)
void(X) (i) Some Variable contained with in Goal
void(Goal) (i) the goal to be satisfied
voidlist(Goal) (i) a list of all objects X that cause Goal to succeed
This is a standard prolog predicate. By the use of the database, all elements X that
match Goal are collected into List. X should be contained within Goal, otherwise you just
get a list of variables whose listlen equals the number of solutions of Goal. As findall is
using call, the Goal predicate must be exported somewhere.
The definition of findall is:
PREDICATE findall(void,void,voidlist). findall(X,Call,_):- % X is contained somewhere in Call asserta(findall_tmp(start)), call(Call), b % call goal (bind X) assertz(findall_tmp(X)), fail. findall(_,_,ResList):- findall_collect(ResList),!. PREDICATE findall_collect(voidlist). % collect results of Call findall_collect([Elem|Rest]):- retract(findall_tmp(Elem)), Elem \= start, findall_collect(Rest). findall_collect().
prolog-process, client-server, object
member , remove , call