English 中文(简体)
道歉执行中的节省产出
原标题:Save output from Prolog execution
  • 时间:2010-12-01 18:50:31
  •  标签:
  • prolog

我正在Prolog使用一种工具,在我执行之后,结果将出现在屏幕上,在Prolog壳体内。 我如何把这一结果复制到另一个档案中?

问题回答

you never said what prolog interpreter you re using. This code works for Edinburgh-compatible version of Prolog, SWI-Prolog (on Fedora) in my case.

如果有文件,请:

 hello_world :- write( Hello World! ).

then

consult( hello ).
qsave_program(hello,[stand_alone(true),goal(hello_world)]).

空档和空壳:

$chmod +x hello
./hello > output_file

it doesn t return to shell when it s done, so you need to find a way to check whether or not your program finished execution and then Ctrl-d and check your output_file hope this helps

从指挥线来看,你可以这样做:

script <file Name>
run your prolog program
exit




相关问题
Prolog : Learning by example

I am trying to learn a little bit about swi-prolog (beyond the basic, useless programs). Can anyone explain (perhaps in pseudocode) what this sudoku solver and the related functions are doing? If ...

Working with lists in Prolog

First off let me state that this is part of a class exercise given as homework. But, the entire assignment is much more involved than the subject of this question. So.. I am searching through two ...

SWI-Prolog conditional statements

I m trying to write a function that will test to see if the word hello is contained in a list. If it is contained, i don t want it to say "true", i want it to say : "yes, the word hello is contained ...

prolog cut off in method

I have a question I would like to ask you something about a code snippet: insert_pq(State, [], [State]) :- !. insert_pq(State, [H|Tail], [State, H|Tail]) :- precedes(State, H). insert_pq(State, [...

Max out of values defined by prolog clauses

I know how to iterate over lists in Prolog to find the maximum, but what if each thing is a separate clause? For example if I had a bunch of felines and their ages, how would I find the oldest kitty? ...

热门标签