in reply to Re^2: One out of three ain't bad
in thread One out of three ain't bad

I'll disagree here an say a form like...
if( !$x && !$y && $z or !$x && $y && !$z or $x && !$y && !$z ) { print "Exactly one..."; }
...is easier to maintain because it is more explicit as to what is required for a truth value. Anyone versed in boolean algebra will easily recognize the sum-of-product form here and instantly grasp the intent.

Replies are listed 'Best First'.
Re^4: One out of three ain't bad
by QM (Parson) on Oct 24, 2005 at 03:35 UTC
    if( !$x && !$y && $z or !$x && $y && !$z or $x && !$y && !$z ) { print "Exactly one..."; }
    I don't think I was clear. I should have added: "How do you expand that for 7, 42, or 105 variables?" It can be done mechanically, fairly easily, but I wouldn't want to end up with an arrangement of 105 x 105, nor would I want to maintain it.

    One might argue that getting from K to K+1 or K-1 variables is also easy (and it is). But I still wouldn't want to deal with it when I could use a list syntax instead.

    Cheers,

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of