next up previous
Next: 4.4 Communication through Linear Up: 4 Using BinProlog Previous: 4.2 Using multiple logic

4.3 Findall/3 with multiple engines

The file library/engines.pl contains some examples of how multiple engines can be used for implementing for instance all-solution predicates. Here is a re-entrant find_all/3.

find_all(X,Goal,Xs):-
  default_engine_params(H,S,T),
  find_all(H,S,T,X,Goal,Xs).

find_all(H,S,T,X,Goal,Xs):-
  create_engine(H,S,T,Handle),
  load_engine(Handle,Goal,X),
  collect_answers(Handle,Xs),
  destroy_engine(Handle).

collect_answers(Handle,[X|Xs]):-ask_engine(Handle,A),!,
  copy_term(A,X),
  collect_answers(Handle,Xs).
collect_answers(_,[]).

default_engine_params(128,32,32).



next up previous
Next: 4.4 Communication through Linear Up: 4 Using BinProlog Previous: 4.2 Using multiple logic



Paul Tarau
Thu Apr 3 10:26:39 AST 1997