In Python, are there builtin functions for elementwise map of boolean operators over tuples of lists
- by bshanks
For example, if you have n lists of bools of the same length, then elementwise boolean AND should return another list of that length that has True in those positions where all the input lists have True, and False everywhere else.
It's pretty easy to write, i just would prefer to use a builtin if one exists (for the sake of standardization/readability).
Here's an implementation of elementwise AND:
def eAnd(*args):
return [all(tuple) for tuple in zip(*args)]
example usage:
>>> eAnd([True, False, True, False, True], [True, True, False, False, True], [True, True, False, False, True])
[True, False, False, False, True]
thx