I am not arguing that it is a generalised xor.

I don’t want anything, I am just gauging if it is specialised or if there is a 
need for it. So just thought could suggest it as I have encountered such need 
several times already.

It is fairly clear by now that it is not a common one given it took some time 
to even convey what I mean. Bad naming didn’t help ofc, but if it was something 
that is needed I think it would have clicked much faster.

Thanks,
DG

> On 14 Nov 2023, at 01:12, Chris Angelico via Python-list 
> <python-list@python.org> wrote:
> 
> On Tue, 14 Nov 2023 at 10:00, Dom Grigonis via Python-list
> <python-list@python.org> wrote:
>> 
>> I am not asking. Just inquiring if the function that I described could be 
>> useful for more people.
>> 
>> Which is: a function with API that of `all` and `any` and returns `True` if 
>> specified number of elements is True.
>> 
>> It is not a generalised `xor` in strict programatic space. I.e. NOT bitwise 
>> xor applied to many bits.
>> This is more in line with cases that `any` and `all` builtins are used.
>> 
> 
> A generalization of XOR is exactly what Grant and I said, though: a
> parity check. See for example:
> 
> https://en.wikipedia.org/wiki/Exclusive_or
> https://reference.wolfram.com/language/ref/Xor.html
> 
> It tells you whether you have an odd or even number of true values.
> 
> Now, if you want something that short-circuits a counting function,
> that's definitely doable, but it's a sum-and-compare, not xor. Also,
> it's quite specialized so it's unlikely to end up in the stdlib.
> 
> ChrisA
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to