如何在 SWI-Prolog 中使用谓词转置? [英] How to use predicate transpose in SWI-Prolog?
问题描述
大家好,我想在 SWI-Prolog 中使用谓词 transpose(Matrix0, Matrix)
,当 Matrix0
和 Matrix
是列表,每个的列"是另一个的行".问题是当我将 :- ensure_loaded(library(clpfd)).
添加到我的源文件中并尝试使用它时,我得到了这个
Hi guys I want to use predicate transpose(Matrix0, Matrix)
in SWI-Prolog which holds when Matrix0
and Matrix
are lists of lists, and the "columns" of each are the "rows" of the other. The problem is when I added :- ensure_loaded(library(clpfd)).
into my source file and tried to use it, I got this
% library(occurs) compiled into occurs 0.00 sec, 14 clauses
% library(apply_macros) compiled into apply_macros 0.00 sec, 44 clauses
% library(assoc) compiled into assoc 0.00 sec, 103 clauses
ERROR: /Users/Benjamin/Documents/prologworkspace/test.pl:27:
import/1: No permission to import clpfd:transpose/2 into user (already imported from ugraphs)
% library(clpfd) compiled into clpfd 0.08 sec, 1,372 clauses
% test compiled 0.08 sec, 1,388 clauses
true.
当我尝试这个时,我得到了 false
:
and I got false
when I try this:
?- transpose([['_','_'],['_','_']], X).
false.
有什么建议吗?谢谢.
推荐答案
import/1:没有权限将clpfd:transpose/2导入用户(已经从ugraphs导入)
import/1: No permission to import clpfd:transpose/2 into user (already imported from ugraphs)
你有名字冲突.这不是 clpfd:transpose/2
本身的问题.
You have a name clash. That's not a problem with the clpfd:transpose/2
itself.
要不导入模块的所有导出谓词,请使用
To not import all exported predicates of a module, use
:- use_module(library(clpfd), []).
然后你需要调用 clpfd:transpose/2
包括命名空间.
Then you need to call clpfd:transpose/2
including the name space.
C.f.
- http://www.swi-prolog.org/pldoc/man?predicate=use_module/2
- http://blog.logtalk.org/2009/03/prolog-modules-madness/
这篇关于如何在 SWI-Prolog 中使用谓词转置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!