Prolog,开始执行写东西

时间:2015-12-23 10:53:37

标签: prolog swi-prolog prolog-toplevel

我想在用户执行时在终端上显示一个字符串。但是,我想在不调用任何谓词的情况下这样做。例如,如果代码是这样的:

print_sth(String):-write(String).

只有在我明确调用该谓词时才会打印一些字符串。相反,当我们咨询我们的程序时,我希望视图是这样的:

This is a brief tutorial of the program that was called automatically. 
?- // Ready to call a predicate here, but the string above was displayed when we consulted the program.  

我尝试了这个,但它不起作用:

:- write('This is a brief tutorial of the program that was called automatically. ').
some_predicate():- do_sth().
// ... other stuff follows here.

谢谢!

1 个答案:

答案 0 :(得分:1)

: - initialization(writeln(' hello world'))。