perl -MData::Dump=pp @values=("true",undef); for $A (@values) { for $B (@values) { pp [$A,$B], [ ($A xor $B), ( ($A && !$B) || ($B && !$A) ) ]; } } __END__ (["true", "true"], ["", ""]) (["true", undef], [1, 1]) ([undef, "true"], [1, 1]) ([undef, undef], ["", undef])
but if you apply De Morgan's law, you'll always get "default" Booleans:
perl -MData::Dump=pp @values=("true",undef); for $A (@values) { for $B (@values) { pp [$A,$B], [ ($A xor $B), !( ( !$A || $B) && (!$B || $A) ) ]; } } __END__ (["true", "true"], ["", ""]) (["true", undef], [1, 1]) ([undef, "true"], [1, 1]) ([undef, undef], ["", ""])
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
In reply to Re^7: 'xor' operator is not a sibling to 'or' and 'and'?
by LanX
in thread 'xor' operator is not a sibling to 'or' and 'and'?
by rsFalse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |