开发者

remove : prolog

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 cod开发者_Python百科e 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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜