Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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.";


Comment on Re^6: One out of three ain't bad (order)
Download Code

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 surveying the Monastery: (8)
As of 2014-12-21 04:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (103 votes), past polls