Logical operators on lists?

0

Hi,

I get a list of boolean values (e.g. from a select function, or when I slice a matrix to another matrix with fewer dimensions), and I want to make “and” or “or” of all these values, returning a single boolean.

Unfortunately, the and/or functions do not work as a summary on lists, the would need two lists, and then work on each element, returning a list. What I want is to work them on all elements on the list, returning a scalar.

As a hack, I now use “sum (list of booleans)” for “or”,  and  not ( sum ( not (list of booleans) )) for “and”, which is a bit clumsy?

Is there a better workaround for this problem?

Is this worth a feature request?

Thanks, Gilbert

S A U Answered question June 9, 2024
1

Gilbert,
what if we use to compute Boolean functions over a vector of Boolean values:

min(list_of_booleans) for AND-logic;
max(list_of_booleans) for OR-logic.

Good luck

S A U Answered question June 9, 2024
You are viewing 1 out of 4 answers, click here to view all answers.