If you want to AND a list of IFs together, then the TRUE output of each IF feeds into the next IF.
IF(A) true ------------------> IF(B) true ------------------> IF(C) true ---------------------> ACTION
.........false NOTHING.............false NOTHING.............false NOTHING
the only way ACTION can excute is if all IF tests output true.
If you want to OR a list of IFs together, then the TRUE output of each IF feeds into the ACTION you want to perform
and the FALSE output of each IF feeds into the next IF.
IF(A) false ------------------> IF(B) false ------------------> IF(C) false ---------------------> NOTHING
.........true ACTION..................true ACTION...................true ACTION
ACTION executes if either test returns TRUE and only once. If all tests fail then the NOTHING route is taken.
General Background: that might help with refactoring logic for easier implementationLogically, solving the problem of transforming list of AND tests into a list of OR tests requires the use of De Morgan's Laws (
https://en.wikipedia.org/wiki/De_Morgan%27s_laws)
This states that
A & B & C & D is equivalent to
~(~A || ~B || ~C || ~D)So for each input as well as the output you negate it with ~ and use || (or) for your logical tests.
....and also that
A || B || C || D is equivalent to
~(~A & ~B & ~C & ~D)So for each input as well as the output you negate it with ~ and use & (and) for your logical tests.
e.g.
where A = 1 B = 1 C = 1 D = 1 and A & B & C & D ---> 1 & 1 & 1 & 1 = true
~(~A || ~B || ~C || ~D) ---> ~(~1 || ~1 || ~1 || ~1) ---> ~(0 || 0 || 0 || 0) ---> ~(0) ---> 1 = true
where A = 0 B = 0 C = 0 D = 0 and A || B || C || D ---> 0 || 0 || 0 || 0 = false
~(~A & ~B & ~C & ~D) ---> ~(~0 & ~0 & ~0 & ~0) ---> ~(1 & 1 & 1 & 1) ---> ~(1) ---> 0 = false
To achieve negation, you either literally negate the input/output or if the variables A,B,C,D are more complex than simple numbers
used here then look for false outputs where you would look for true and look for true outputs where you would look for false as
negating complex variables requires using De Morgans Law on each variable to negate it.
Hope this helps