Prolog,在开始执行时写一些东西
Prolog, on start executing write something
我想在用户执行时在终端上显示一个字符串。但是,我想在不调用任何谓词的情况下执行此操作。例如,如果代码是这样的:
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.
谢谢!
:- initialization(writeln('hello world')).
我想在用户执行时在终端上显示一个字符串。但是,我想在不调用任何谓词的情况下执行此操作。例如,如果代码是这样的:
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.
谢谢!
:- initialization(writeln('hello world')).