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.
精彩评论