質問

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

役に立ちましたか?

解決

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'.
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top