I'm writing a partial-evaluator for Prolog queries. I tried to expand a query using expand_goal/2
, but it simply unifies the Input
with the Output
in this case:
:- initialization(main).
main :-
Input=is_between(1,A,3),expand_goal(Input,Output),writeln(Output).
is_between(A,B,C) :-
B>A,B<C.
I also tried using term_expansion/2
, but this causes the program to fail:
:- initialization(main).
main :-
Input=is_between(1,A,3),term_expansion(Input,Output),writeln(Output).
is_between(A,B,C) :-
B>A,B<C.
Does SWI-Prolog have a built-in predicate that can perform macro-expansion of queries at runtime, as I tried to do here?
goal_expansion/2
? – Cherie