Note that there are some explanatory texts on larger screens.

plurals
  1. POBesides AND/OR/NOT, what's the point of the other logical operators in programming?
    primarykey
    data
    text
    <p>I've been programming nearly all of my life (around 20+ years), and I don't think I can remember a single time when I was looking at a if-statement and think "Hmmm, this would be a good time to use XOR." The entire logical programming universe seems to revolve around just these three.</p> <p>Granted, with AND/OR/NOT gates, you can make any other logical statement. However, there might be a time where it might save you some code to combine two or three statements into a single logical statement. Let's look at the 16 possible combinations of <a href="http://en.wikipedia.org/wiki/Logical_connective#Table_of_binary_logical_connectives" rel="nofollow">logical connectives</a>:</p> <ol> <li>FALSE = Contradiction = 0, null, NOT TRUE</li> <li>TRUE = Tautology = 1, NOT FALSE</li> <li>X = Proposition X = X</li> <li>NOT X = Negation of X = !X</li> <li>Y = Proposition Y = Y</li> <li>NOT Y = Negation of Y = !Y</li> <li>X AND Y = Conjunction = NOT (X NAND Y)</li> <li>X NAND Y = Alternative Denial = NOT (X AND Y), !X OR !Y</li> <li>X OR Y = Disjunction = NOT (!X AND !Y)</li> <li>X NOR Y = Joint Denial = NOT (X OR Y), !X AND !Y</li> <li>X ⊅ Y = Material Nonimplication = X AND !Y, NOT(!X OR Y), (X XOR Y) AND X, ???</li> <li>X ⊃ Y = Material Implication = !X OR Y, NOT(X AND !Y), (X XNOR Y) OR X, ???</li> <li>X ⊄ Y = Converse Nonimplication = !X AND Y, NOT(X OR !Y), (X XOR Y) AND Y, ???</li> <li>X ⊂ Y = Converse Implication = X OR !Y, NOT(!X AND Y), (X XNOR Y) OR Y, ???</li> <li>X XOR Y = Exclusive disjunction = NOT (X IFF Y), NOT (X XNOR Y), X != Y</li> <li>X XNOR Y = Biconditional = X IFF Y, NOT (X XOR Y), !X AND !Y</li> </ol> <p>So, items 1-2 involve zero variables, items 3-6 involve one, and items 7-10 are terms we are familiar with. (Though, we don't usually have a NAND operator, but at least Perl has "unless" for universal NOT.)</p> <p>Items 11-14 seem like interesting ones, but I've never seen these in programming. Items 15-16 are the XOR/XNOR.</p> <p>Can any of these be used for AND/OR/NOT simplification? If so, have you used them?</p> <p><strong>UPDATE:</strong> "Not equal" or != is really XOR, which is used constantly. So, XOR is being used after all.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload