为什么这个 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
I have a prolog program. These lines are preventing it from 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),
(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
I get the following errors:
| ?- [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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
/=
不是有效的运算符。您的意思一定是\=
。(更好的是,如果您的 Prolog 支持,请使用
dif(A,B)
,并将dif
调用放在子句的其余部分之前。)/=
is not a valid operator. You must have meant\=
.(Better yet, use
dif(A,B)
if your Prolog supports it, and put thedif
calls before the rest of the clause.)