gpt4 book ai didi

Prolog,在开始执行时写一些东西

转载 作者:行者123 更新时间:2023-12-02 03:19:27 24 4
gpt4 key购买 nike

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

print_sth(String):-write(String).

只有当我显式调用该谓词时,它才会打印一些字符串。相反,当我们查询我们的程序时,我希望 View 是这样的:

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')).

关于Prolog,在开始执行时写一些东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34434038/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com