如何关闭 SWI-Prolog 标志? [英] How do I turn off SWI-Prolog flags?
问题描述
我不确定 flags 是否合适,但无论如何配置一个 swi-prolog 程序在查询完成时不输出真或假,而是简单地打印出程序中确定的另一个语句?
I'm not sure if flags is the appropriate term, but is there anyway to configure a swi-prolog program to not output true or false on the completion of a query, and instead simply print out another statement determined in the program?
推荐答案
有一种工具可以自定义这种行为,但它可能会非常复杂.我自己没有玩过它,但查看手册和 Prolog 启动文件可能会对您有所帮助.
There is a facility for customising this kind of behaviour, but it can get quite involved. I have not played with it myself but looking at the manual and Prolog boot files might help you.
Prolog 有一个顶级",它是一小段 Prolog 代码,用于控制 Prolog 命令行并执行在其上输入的目标.使用 SWI-Prolog,您可以指定替代的顶级:
Prolog has a "top level", which is a bit of Prolog code that controls the Prolog command line and executes the goals entered on it. With SWI-Prolog, you can specify an alternative top level:
pl -t my_quiet_prolog
如果您在启动时加载的文件中定义了 my_quiet_prolog/0
,例如在您的 ~/.plrc
文件中.
If you define my_quiet_prolog/0
in a file loaded on startup, e.g. in your ~/.plrc
file.
默认的顶层称为 prolog/0
.这个源代码和默认 Prolog 环境的其他部分可以在 /usr/lib/pl-5.6.36/boot
中找到(在我的 Cygwin 系统上;对你来说可能不同).查看 toplevel.pl
以获取默认顶级.消息是"和否"也在 messages.pl
中定义.
The default top level is called prolog/0
. The source for this, and other parts of the default Prolog environment can be found in /usr/lib/pl-5.6.36/boot
(on my Cygwin system; possibly different for you). Look at toplevel.pl
for the default top level. The messages 'Yes' and 'No' are also defined, in messages.pl
.
您可以尝试覆盖消息,或者简单地复制顶层并修改它以适合您.
You could try to override the messages, or simply copy the top level and modify it to suite you.
这篇关于如何关闭 SWI-Prolog 标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!