Logical operations: Difference between revisions
m
→{{header|J}}
m (→{{header|J}}) |
m (→{{header|J}}) |
||
Line 1,857:
An alternate approach, based on a probabilistic interpretation, uses <code>*</code> for logical and, <code>-.</code> for logical negation and derives the others: <code>(*&.-.)</code> for logical or, <code>(-.@*)</code> for not-and, <code>(-.@*&.-.)</code> for not-or, <code>(* *&.-. -.@*&.-.)</code> for exclusive or, and <code>(*&.-. -.)~</code> for logical implication. You get the same results for simple truth values this way, but you also get consistent treatment for values between 0 and 1.
That said, J also supports truth valued operations on the binary representations of integers. (This is the concept of "packed binary", roughly speaking). For example <code>2b10001
<lang J> (2b10001 b. table/~i.4);(2b10110 b. table/~i.4);<2b10000 b. table/~i.4
|