如何在Prolog中包含.pl文件? [英] How do I include a .pl file in Prolog?
本文介绍了如何在Prolog中包含.pl文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
: - [foo]来包含它。
或等价地更明确
: - consult(foo)。
或者,如果您担心可能会在更大的应用程序中加载好几次
: - ensure_loaded(foo)。
或者,如果您使用 full-blown modules
: - use_module富)。
尽管Prolog版本中最后一个谓词的确切名称不同。
I'd like to include code from another source file. Does anyone know how to do that?
解决方案
If your file is called foo.pl
, you can include it using
:- [foo].
or, equivalently and a bit more explicit
:- consult(foo).
or, if you're worried it may be loaded several times in a larger app
:- ensure_loaded(foo).
or, if you're using full-blown modules
:- use_module(foo).
though the exact name of the last predicate differs between Prolog versions.
这篇关于如何在Prolog中包含.pl文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文