开发者

Prolog Conditional Not Evaluating

I'm trying to simply do a conditional in prolog like this:

((Life==dead)->Trans=no).

I thought the above code would evaluate as if Life == dead, then Trans = no, but for some reason its not? Thank开发者_JAVA百科s.


Works for me:

?- ((Life==dead)->Trans=no).
false.

?- Life = dead, ((Life == dead) -> Trans=no).
Life = dead,
Trans = no.

Life == dead will only be true if Life is already bound to dead.

Also, this is a rather strange construct that it is rarely needed in practice, (x -> y ; z) is much more common.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜