If you are using SWI-Prolog, you can use with_output_to/2
. To write, for example, to an atom, you say:
?- with_output_to(atom(A), portray_clause(foo(X) :- bar)).
A = 'foo(_) :-\n\tbar.\n'.
Question
Is there a way so that portray_clause is written to a variable instead of standard output?
?- portray_clause(f(x):app(X, Y, Z)).
f(x):app(_, _, _).
true.
?- portray_clause(Output, f(x):-app(X, Y, Z)).
ERROR: Arguments are not sufficiently instantiated
Thank you in advance
La solution
If you are using SWI-Prolog, you can use with_output_to/2
. To write, for example, to an atom, you say:
?- with_output_to(atom(A), portray_clause(foo(X) :- bar)).
A = 'foo(_) :-\n\tbar.\n'.