TransWikia.com

Is there a way to simplify redundant conditionals?

Computer Science Asked on October 21, 2021

For example if I’ve this:

if a == false then return true else
if a == true and b == false return true else
if a == true and b == true then return false

can be simplified to

if a == false || b == false then return true
return false;

Truth Table would look like this:

F T = T
F F = T
T F = T
T T = F

I want to come up with a solution that can get arbitrarily big conditional but condense it to the minimum state and get rid of cases which will never occur.

I’d imagine one way would be to generate a truth table and work your way up from there, another would be to find and combine combos with similar out comes and come up with a pattern that would keep the existing truth table intact.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP