我有一个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
答案 0 :(得分:2)
/=
不是有效的运算符。你的意思是\=
。
(更好的是,如果您的Prolog支持它,请使用dif(A,B)
,并将dif
调用放在该子句的其余部分之前。)