# Sum or add depending of true or false

Hello

I have list of values por example 1 1 1 1 1 1 1 1 1 1
and i also have a list of true false : true true true false true true true true true true
and the index : 0 1 2 3 4 5 6 7 8 9
the index 3 is a false
is t possible for example just add a number, for example 5 only to the false or true?
The list would be like this : 6 6 6 1 6 6 6 6 6 6

Thanks a lot

i meant this, but i dont know if it is very ellegant.

You can use implicit conversions.

ANY number can be converted to a boolean, and only “0” (zero) is “false”, the other are all true, even negative.
Only “true” and “false” string text can be converted to booleans.
(EDIT: if a string text is implicitly convertible to a number, like “0.0”, “pi”, etc… GH will do a double implicit conversion string>number>boolean … like “50.37” in the pic)
Booleans can be converted to integer or number as equal to 0 (false) and 1 (true).

Knowing this you can do you logic with very few elements.

1 Like

You can also use `Sift Pattern`.

SiftPattern.gh (10.8 KB)

1 Like

or like this:

I thought i could be done with the expression component since its just a single condition, nut didnt got it to work
Edit, found it with expression:

, but maybe I am missing the point

Never ever used Sift pattern and Combine components, now I learnt about them in a flash!
Thank you!