views:

128

answers:

1

Hi, 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? Thanks.

+3  A: 

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.

starblue