问题
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.
and I got false
when I try this:
?- transpose([['_','_'],['_','_']], X).
false.
Any suggestion? Thank you.
回答1:
import/1: No permission to import clpfd:transpose/2 into user (already imported from ugraphs)
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), []).
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/
来源:https://stackoverflow.com/questions/26477057/how-to-use-predicate-transpose-in-swi-prolog