Page 1 of 1

OR Logical Operator

Posted: 14 May 2020 16:21
by rasvprolog
I would appreciate if anyone can suggest proper punctuation for an OR operator. DeBoer Guide suggests";" but using that causes error. In the example below the following predicate succeeds if xpositive2(_,1,9) AND xpositive2(_,4,11) both are true. If the intention is for the predicate to succeed if xpositive2(_,1,9) OR xpositive2(_,4,11) either one is true, what is the proper punctuation.

Code: Select all

cause("Success",CFI,CFO):-                 xpositive2(_,1,9),                 xpositive2(_,4,11),                             CFO=CFI+0.05,!.
Thanks in advance,
Frank

Re: OR Logical Operator

Posted: 14 May 2020 17:46
by Harrison Pratt
Parentheses are your friends!

Code: Select all

    cause("Success", CFI, CFO) :-         (xpositive2(_, 1, 9) or xpositive2(_, 4, 11)),         CFO = CFI + 0.05,         !.
Also, if you use ";" as a substitute for "or" the IDE will politely change ";" to "or" to use the more visually obvious form! :-)

Re: OR Logical Operator

Posted: 15 May 2020 2:05
by rasvprolog
Harrison, Thank you Thank you....