On Sat, Mar 20, 2004 at 03:09:15PM -0500, Austin Hastings wrote:
> Let's look at boolean xor:
> 
>   if ($a xor $b xor $c) {...}
> 
> should succeed only when exactly one of ($a, $b, $c) is true. This corresponds 
> roughly to constructing and then collapsing a one() junction:

That's not the definition of xor that I learned in school.
It's taking a simplified form of the definition that works
for two arguments and then expanding it to multiple
arguments - but the result is different from the original
definition of xor.

The truth table for xor is:

 x y  | x xor y
------+--------
 0 0  |    0
 0 1  |    1
 1 0  |    1
 1 1  |    0

If you look at the first two rows, the result is equalt to y:
zero xor'ed with y is y.  The last two rows shot that one
xor'ed with y is the complement of y.  Every 1 in a list of
values being xor'ed together complements the result. So:

    $a xor $b xor $c

is true when either one or three of ($a, $b, $c) are true,
and false when zero or two of them are true.  This
characteristic of xor gets used in many places: cryptography
and secure hash computations, for example, or RAID parity
value for another.

Since the one function already exists, there is no need to
change the meaning of the xor function.

Reply via email to