How do I turn off SWI-Prolog flags?

可紊 提交于 2019-12-25 01:39:18

问题


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?


回答1:


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 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

If you define my_quiet_prolog/0 in a file loaded on startup, e.g. in your ~/.plrc file.

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.



来源:https://stackoverflow.com/questions/10490598/how-do-i-turn-off-swi-prolog-flags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!