如何在 Prolog 中包含 .pl 文件?
我想包含另一个源文件中的代码。有谁知道该怎么做?
I'd like to include code from another source file. Does anyone know how to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我想包含另一个源文件中的代码。有谁知道该怎么做?
I'd like to include code from another source file. Does anyone know how to do that?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
如果您的文件名为
foo.pl
,您可以使用or 包含它,等效地并且更明确一点
,或者,如果您担心它可能会在较大的应用程序中加载多次
,或者,如果您正在使用成熟的模块,
尽管 Prolog 之间最后一个谓词的确切名称有所不同版本。
If your file is called
foo.pl
, you can include it usingor, equivalently and a bit more explicit
or, if you're worried it may be loaded several times in a larger app
or, if you're using full-blown modules
though the exact name of the last predicate differs between Prolog versions.
如果您想按字面意思包含该文件 - 类似于 #include,请使用
:- 包括('file.pl')。
大多数时候最好使用以下方式构建程序
不过,模块。
If you want to include the file literally - similar to #include, use
:- include('file.pl').
Most of the time it is preferable to structure your program using
modules, though.