OR Logical Operator

Discussions related to Visual Prolog
rasvprolog
Active Member
Posts: 29
Joined: 1 May 2014 3:28

OR Logical Operator

Unread post by rasvprolog » 14 May 2020 16:21

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
FR

Harrison Pratt
VIP Member
Posts: 323
Joined: 5 Nov 2000 0:01

Re: OR Logical Operator

Unread post by Harrison Pratt » 14 May 2020 17:46

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! :-)

rasvprolog
Active Member
Posts: 29
Joined: 1 May 2014 3:28

Re: OR Logical Operator

Unread post by rasvprolog » 15 May 2020 2:05

Harrison, Thank you Thank you....
FR

Post Reply