I have this code:
switch (c) {
case '-': break;
case '0': e = expr(j).reduce(C1); e=not(e); a = and(a, e); break;
case '1': e = expr(j).reduce(C1); a = and(a, e); break;
default: throw new Exception("Unexpected cube value, " + c);
}
The cases 0 and 1 are only different by not
. I do not like to encode the necessity to invert
into the arguments of the and
function,
switch (c) {
case '-': break;
case '0': a = and(true, a, e); break;
case '1': a = and(false, a, e); break;
default: throw new Exception("Unexpected cube value, " + c);
}
because this will need a conditional if (invert) e = inv(e);
in the function, whereas we already established the need to invert when resolved the switch.
I mean that in case1
you know that you do not need any inv
. In case0
, you know that you need one. If you now merge the cases, you will need one more if
to resolve between case1
(inv
is not needed) and case0
(inv
is needed) once again.
a
ande
? What doesand
though? What doesexpr(j).reduce(C1)
do? You don't need to provide the code for them, just explain what it is doing and what types you are using. \$\endgroup\$a
,e
booleans or some more exotic structure? \$\endgroup\$BigInteger
is appropriate? I encourage you to post the entire function, probably as a separate question referencing this one. \$\endgroup\$if (c == '-') handleThatcase(); else duplicateOfYourPreviousQuestion();
\$\endgroup\$