Reputation: 2787
In this mcve]
test :-
tell('junk.txt'),
print_term(
examples([this,is,a,really,long,example,list],
[made,of,lists,atoms,and,including,terms(involving,parentheses,like,this)]),
[]),
told.
SWI-PROLOG does print the term to the screen neatly in the print_term
way, but won't print it to the file. How do I redirect the output?
Upvotes: 1
Views: 98
Reputation: 22585
You may use current_output/1
to get the current Stream and then pass it to print_term/2
in its Options
parameter:
test :-
tell('junk.txt'),
current_output(Stream),
print_term(
examples([this,is,a,really,long,example,list],
[made,of,lists,atoms,and,including,terms(involving,parentheses,like,this)]),
[output(Stream)]),
told.
I believe all those Edinburgh style predicates that deal with files are in maintenance mode and you now may prefer to use ISO stream predicates.
Upvotes: 1