1% * -*- Mode: Prolog -*- */
    2
    3:- module(embed,
    4          [
    5	   eval_bagof/3
    6           ]).
*/
   14:- use_module(library(biomake/biomake)).   15
   16% We have to redefine these operators, ugh
   17:- user:op(1100,xfy,<--).   18:- user:op(1101,xfy,?=).   19:- user:op(1102,xfy,:=).   20:- user:op(1103,xfy,+=).   21:- user:op(1104,xfy,=*).   22
   23% although it is called from another module, eval_bagof has to be in this module
   24% because term assertions from the makeprog go in this namespace.
   25eval_bagof(TemplateStr,GoalStr,Result) :-
   26    format(atom(BagofAtom),"bagof(~w,~w,List)",[TemplateStr,GoalStr]),
   27    atom_to_term(BagofAtom,BagofTerm,Bindings),
   28    call_without_backtrace(BagofTerm),
   29    member(('List' = List), Bindings),
   30    atomic_list_concat(List," ",Result),
   31    !.
   32eval_bagof(_,_,"")