newbie question about type error, fd_domains and gprolog
- From: Josh Smith <josh+news@xxxxxxxxxxx>
- Date: Mon, 16 May 2005 15:11:16 -0500
Given the following simple prolog code:
------ CUT ---------
needs(bob,[one,two]).
needs(bill,[three,four,one]).
provides(prod1,[three,four,one]).
provides(prod2,[one]).
provides(prod3,[two,four,three]).
provides(prod4,[one,two,three,four]).
contains([],_).
contains([M|N],Y) :- fd_domain(M, Y),fd_labeling(M),contains(N,Y).
%contains([M|N],Y):-member(M,Y),contains(N,Y).
whoprovides(X,Y):-provides(X,Z),member(Y,Z).
cangointo(X,Y):-needs(X,Z),provides(Y,Q),contains(Z,Q).
------ CUT ---------
I get a type error:
| ?- cangointo(X,Y).
uncaught exception: error(type_error(list,one),fd_domain/2)
Hoever, when I use the member/recursive version I get the expected:
| ?- cangointo(X,Y).
X = bob
Y = prod4 ? ;
X = bill
Y = prod1 ? ;
X = bill
Y = prod4 ? ;
I don't understand why this is happening and if anyone can help this newbie
get his head around this I would be hugely greatful. TIA.
-jbs
.
- Prev by Date: Re: f(a:-b,c) or f((a:-b),c) - How should compound args be parsed?
- Next by Date: comp.lang.prolog Frequently Asked Questions
- Previous by thread: MYCIN type Certainty Reasoning
- Next by thread: Can i make a variable like those in imperative language ?
- Index(es):