Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^6: One out of three ain't bad (order)

by sauoq (Abbot)
on Oct 26, 2005 at 04:39 UTC ( #502942=note: print w/ replies, xml ) Need Help??


in reply to Re^5: One out of three ain't bad (order)
in thread One out of three ain't bad

In fact, the multiplication symbol (the middle-dot, ) was reused for the "and" operator, and the addition symbol (+) was reused for the "or" operator, IIRC (which I may not recall correctly...).

You recall correctly. Some people find it counterintuitive that 'plus' (+) should be used for 'or' because, in natural language, we often use 'plus' as an informal conjunction meaning 'and'. But... it makes perfect sense when you compare the boolean algebra operators with their counterparts in arithmetic...

ABA and BA times B
0000
0100
1000
1111

ABA or BA plus B
0000
0111
1011
1112

So, addition is essentially boolean disjunction with the added feature of counting how many clauses are true. Having more than two values comes in handy. (Note that xor is the same as addition modulus 2.) The OP's query can be answered using only standard boolean algebra operators, of course. $x xor $y xor $z and not ($x and $y) would be one way.

-sauoq
"My two cents aren't worth a dime.";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://502942]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2016-06-25 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (326 votes). Check out past polls.