ERROR: No procedure usermod : select / 3 exists

ERROR: No procedure usermod : select / 3 exists

我正在学习序言并且在使用 select/3 谓词时遇到问题,所以我为它制作了一个测试文件。

我正在尝试 运行 的整个代码是其自身文件中的以下 1 行 XSB:

find(X,B) :- select(X, [1,2,3,4,5], B).

编译正常,但出现以下错误:

| ?- find(5,B).
++Error[XSB/Runtime/P]: [Existence (No procedure usermod : select / 3 exists)] []
Forward Continuation...
... machine:xsb_backtrace/1  From c:/program files (x86)/XSB/syslib/machine.xwam
... x_interp:_$call/1  From c:/program files (x86)/XSB/syslib/x_interp.xwam
... x_interp:call_query/1  From c:/program files (x86)/XSB/syslib/x_interp.xwam
... standard:call/1  From c:/program files (x86)/XSB/syslib/standard.xwam
... standard:catch/3  From c:/program files (x86)/XSB/syslib/standard.xwam
... x_interp:interpreter/0  From c:/program files (x86)/XSB/syslib/x_interp.xwam
... loader:ll_code_call/3  From c:/program files (x86)/XSB/syslib/loader.xwam
... loader:load_object_file/2  From c:/program files (x86)/XSB/syslib/loader.xwam
... standard:call/1  From c:/program files (x86)/XSB/syslib/standard.xwam
... standard:catch/3  From c:/program files (x86)/XSB/syslib/standard.xwam

据我所知,这个错误通常是在用户定义的谓词出现问题时出现的,但这是一个标准函数,文档说它会自动导入,所以为什么我会收到这个错误?

select/3谓词是一个普通的库谓词。看起来,尽管使用 XSB,您正在阅读另一个 Prolog 系统文档。可能是 SWI-Prolog,它提供了 XSB 中不存在的自动加载机制。但是您可以手动导入谓词。例如:

$ xsb
[xsb_configuration loaded]
[sysinitrc loaded]
[xsbbrat loaded]

XSB Version 3.8.0 (Three-Buck Chuck) of October 28, 2017
[i386-apple-darwin18.7.0 64 bits; mode: optimal; engine: slg-wam; scheduling: local]
[Build date: 2019-12-13]

| ?- import select/3 from lists.

yes
| ?- select(X, [1,2,3,4,5], B).

X = 1
B = [2,3,4,5];

X = 2
B = [1,3,4,5];

X = 3
B = [1,2,4,5];

X = 4
B = [1,2,3,5];

X = 5
B = [1,2,3,4];

no

要将导入添加到您的源文件,请将其作为指令写在文件的开头:

:- import select/3 from lists.