为什么这个prolog程序没有编译?

时间:2011-03-31 19:57:52

标签: compiler-errors prolog prolog-dif

我有一个prolog程序。这些行阻止它编译:

wins(A,B,C,D) :- convert(A,W), value(W,P), convert(B,X), value(X,Q), 
convert(C, Y), value(Y,R), convert(D,Z), value(Z,S), card(A), card(B), card(C), card(D),
(P+Q)>(R+S), (P+Q)<22, A/=B, A/=C, A/=D, B/=C, B/=D, C/=D. %this is not compiling

wins(A,B,C,D) :- convert(A,W), value(W,P), convert(B,X), value(X,Q), 
convert(C,Y), value(Y,R), convert(D,Z), value(Z,S), card(A), card(B), card(C), card(D),
(R+S)>21, (P+Q)<22, A/=B, A/=C, A/=D, B/=C, B/=D, C/=D. %this is not compiling

我收到以下错误:

| ?- [blackjack].
compiling /home/ross/flash/current/CS390/blackjack.pl for byte code...
/home/ross/flash/current/CS390/blackjack.pl:47:25: syntax error: . or operator expected after expression
/home/ross/flash/current/CS390/blackjack.pl:51:22: syntax error: . or operator expected after expression
2 error(s)
compilation failed

1 个答案:

答案 0 :(得分:2)

/=不是有效的运算符。你的意思是\=

(更好的是,如果您的Prolog支持它,请使用dif(A,B),并将dif调用放在该子句的其余部分之前。)