xor operator

Dom Grigonis dom.grigonis at gmail.com
Mon Nov 13 16:35:32 EST 2023


xor([True, False, False, False], n=1)
xor([False, False, False, True], n=1)
Both of the above would evaluate to true.

Well, it depends how you interpret it.
In binary case it reads: “exclusively one positive bit or the other, but not both”
In this case one could read: “exclusively one positive set of certain length, but not more than one such set at the same time" 

But I completely see how one could argue, that “exclusive” refers to slightly different thing. And multivariate `xor` is a function which defines fixed subsets out of which only one is true, but not the others, but this is theoretical, as in practice each set would need to always have all values switched on or off, which boils down to my proposed `xor` with `n=1`.

But the point is if there is a need for such function or I am the only one who happens to use it.

DG

> On 13 Nov 2023, at 23:03, Barry <barry at barrys-emacs.org> wrote:
> 
> 
> 
>> On 13 Nov 2023, at 17:48, Dom Grigonis <dom.grigonis at gmail.com> wrote:
>> 
>> Short circuiting happens, when:
>> xor([True, True, False, False], n=1)
>> At index 1 it is clear that the answer is false.
> 
> Can you share an example with 4 values that is true?
> And explain why it is xor.
> 
> Barry
> 



More information about the Python-list mailing list