문제

I am trying to compile csp.pl from "Computational Intelligence book" which solves the constraint satisfaction problem. I want to use this as a base to solve crossword puzzle generator.

But when I try to run the code it gives

 Existence error in user:remove/3
! procedure user:remove/3 does not exist
! goal:  user:remove([1,2,3,4],3,_127)
| ?- :-

I think remove is not a built-in predicate

% select(E,L,L1) selects the first element of
% L that matches E, with L1 being the remaining
% elements.
select(D,Doms,ODoms) :-
   remove(D,Doms,ODoms), !.

% choose(E,L,L1) chooses an element of
% L that matches E, with L1 being the remaining
% elements.
choose(D,Doms,ODoms) :-
   remove(D,Doms,ODoms).

This is the part of the code... Can anyone please help me fix this issue... Code should execute since in the textbook its claimed to hv run on some programs..

Please help

도움이 되었습니까?

해결책

I don't think remove is part of any Prolog library -- certainly not SWI Prolog. The list library is here.

There is a predicate delete which does the same thing that code uses remove for. So just find-and-replace and it should work.

다른 팁

Load the lists library using

:- use_module(library(lists)).

This gives you access to the lists:select/3 predicate, which does what your choose/3 should do. lists:delete/3 is almost your remove/3, except with the arguments in a different order.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top