我正在阅读Prolog教程.它告诉我可以通过输入以下命令加载其他prolog文件:
[filename].
Run Code Online (Sandbox Code Playgroud)
但每次我试着这样做
ERROR: load_files/2: Arguments are not sufficiently instantiated.
Run Code Online (Sandbox Code Playgroud)
该文件与我正在工作的目录位于同一目录中.
这是整个查询和错误的副本:
12 ?- [KB5].
ERROR: load_files/2: Arguments are not sufficiently instantiated
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
JUS*_*ION 24
$ cat junk.pl
test(ok).
$ prolog
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 5.8.0)
Copyright (c) 1990-2009 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
?- [junk].
% junk compiled 0.00 sec, 24 bytes
true.
Run Code Online (Sandbox Code Playgroud)
它对我来说似乎很好.当然我使用原子作为我的文件名,而不是变量.(KB5是变量名,而不是原子.)首先尝试['KB5']看看是否有帮助.接下来试试看[kb5]是否有帮助.最后尝试一个绝对最小的例子,就像我提供的那样,看看你是否可以加载.
编辑添加:
$ cp junk.pl JUNK.pl
$ prolog
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 5.8.0)
Copyright (c) 1990-2009 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
?- [JUNK].
ERROR: load_files/2: Arguments are not sufficiently instantiated
?- ['JUNK'].
% JUNK compiled 0.00 sec, 1,656 bytes
true.
Run Code Online (Sandbox Code Playgroud)
它确实看起来像原子问题.使用['KB5']和您的错误可能会消失.
小智 13
虽然提供了另一种方法.这是一个替代方案:
?- consult('C:/User/Folder/myRules.pl').
Run Code Online (Sandbox Code Playgroud)
这应该够了吧!