xor operator
Dom Grigonis
dom.grigonis at gmail.com
Mon Nov 13 17:58:58 EST 2023
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.
> On 14 Nov 2023, at 00:51, Grant Edwards via Python-list <python-list at python.org> wrote:
>
> On 2023-11-13, Dom Grigonis via Python-list <python-list at python.org> wrote:
>> Hi All,
>>
>> I think it could be useful to have `xor` builtin, which has API similar to the one of `any` and `all`.
>>
>> * Also, it could have optional second argument `n=1`, which
>> * indicates how many positives indicates `True` return. For
>> * complete flexibility 3rd argument could indicate if `the number`
>> * is equal, greater, less, ... than `n`
>
> I would expect "xor" to return true if there are an odd number of
> trues, and false if there are an even number of trues. It's not clear
> to me what you're asking for.
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list