all.
I want to assign a boolean value to a variable.
I’ve tried stuff like.
Diagonal is (XPiece = XFinal)
Diagonal is (XPiece =:= XFinal)
Diagonal is (XPiece is XFinal)
None work…
Any solutions?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Prolog’s built-in predicate
is/2evaluates the right-hand side of the expression as an arithmetic expression and unifies the result with the left-hand side.Also, prolog doesn’t have a boolean type. Prolog’s built-in types are
You could elect to represent a boolean value as the atoms
true/false(useful for readability), or you could represent a boolean value as the integer values1/0(useful for computation). The way most procedural languages, like C, evaluate arithmetic values as booleans is broken WRT formal logic, though: falsity is single-valued (0) and truth multi-valued (non-zero), meaning that which is not false. In formal logic, truth is single-valued and falsity is defined as that which is not true.So you might want to consider the semantics of your representation and build some predicates to manipulate your booleans, possibly adding some operators to “extend” prolog a bit.