Sum list booleans: true + false = false

Hi,

small question.

There is list A: containing 12 items true/false
There is list B: containing 12 items true/false

I would like to ‘add’ these list in this way, that;
true + true = true
true + false = false
false + true = false
false + false = false,

any suggestions?

thanks

2020-09-22 True + False = False.gh (5.5 KB)

Like this?


2020-09-22 True + False = False_re.gh (8.3 KB)

That sounds like multiplication to me. But your test data is boring! So I used @HS_Kim’s data instead:

True + False = False_2020Sep21a
True + False = False_2020Sep21a.gh (7.5 KB)

Or if you prefer Boolean results:

True + False = False_2020Sep21a2
True + False = False_2020Sep21aa.gh (8.9 KB)

You can use expression

true + true = true
true + false = false
false + true = false
false + false = false,


true is 1 and false is 0
in your post this is wrong :
true + false = false
false + true = false

Is that not just a logical AND?


2020-09-22 True + False = False.gh (7.0 KB)

The built-in AND component has given me some grief in the past with how it handles a mix of nulls and bools… for example, if you feed in a null and a true, it will output true, so I’ve sometimes used a python implementation of the AND operator instead.

4 Likes

Yes this is the simplest way