Difference between revisions of "Or"
Jump to navigation
Jump to search
(Created page with "<c>or</c> is a keyword for logical binary operator of disjunction (or) of [https://en.wikipedia.org/wiki/Boolean_algebra boolean algebra]. It evaluates...") |
|||
| Line 1: | Line 1: | ||
| − | <c>or</c> is a [[:Category:Keywords|keyword]] for logical binary operator of disjunction (or) of [https://en.wikipedia.org/wiki/Boolean_algebra boolean algebra]. It evaluates two operands and returns <c>true</c> when at least one of the operands is <c>true</c>, else it returns <c>false</c>. | + | <c>or</c> is a [[:Category:Keywords|keyword]] for logical binary operator of disjunction (or) of [https://en.wikipedia.org/wiki/Boolean_algebra boolean algebra] and [[Fuzzy Logic]]. It evaluates two operands and returns <c>true</c> when at least one of the operands is <c>true</c>, else it returns <c>false</c>. |
| + | |||
| + | More specifically, <c>a or b</c> (where ''a'' and ''b'' are numbers) evaluates to the absolute value of the expression <c>a + b - (a * b)</c>, clamped to the range 0 - 1. | ||
== Examples == | == Examples == | ||
| Line 7: | Line 9: | ||
print true or false // output : 1 | print true or false // output : 1 | ||
print true or true // output : 1 | print true or true // output : 1 | ||
| + | print 0.8 or 0.5 // output : 0.9 | ||
a = false | a = false | ||
Revision as of 20:38, 29 January 2025
or is a keyword for logical binary operator of disjunction (or) of boolean algebra and Fuzzy Logic. It evaluates two operands and returns true when at least one of the operands is true, else it returns false.
More specifically, a or b (where a and b are numbers) evaluates to the absolute value of the expression a + b - (a * b), clamped to the range 0 - 1.
Examples
print false or false // output : 0
print false or true // output : 1
print true or false // output : 1
print true or true // output : 1
print 0.8 or 0.5 // output : 0.9
a = false
b = true
c = false
print a or b // output : 1
print b or c // output : 1
print a or c // output : 0
minimum = 3
maximum = 7
A = 4
B = 9
print A > minimum or B < maximum // output : 1
print A < minimum or B < maximum // output : 0