10

I hate complex boolean logic.

(true||false) && true || false || (true && false) ... etc (continue for at least ten clauses four times as long)

Comments
  • 10
    Best practice is to break that expression out into a function and comment the fuck out of the logic with lots of apologies.
  • 3
    I've just spent several minutes wondering whether you could create booleans with real and imaginary components like complex numbers.

    I have concluded that a) you probably can't, and b) I've forgotten how to do maths.
  • 1
    now look into prepositional calculus and the kind of logic you can express with things like Prolog or Clingo.

    I hate it too
  • 5
    State machines? Anyone?
  • 2
    @donkulator
    troll && troll -> false
    troll || troll -> troll
    troll && false -> troll
    troll && true -> troll
    troll || false -> troll
    troll || true -> true
  • 3
    Divide and conquer. Assign to temp variables with meaningful names of each variable. Create final expression by combining these variables into the expression.
  • 1
    @Demolishun exactly! πŸ‘Œ
  • 0
    Yeah I agree. But this one evaluates to true. Just sayin' 🀷
  • 2
    I find it entertaining to try to simplify them applying Boole algebra. Truth tables, Karnaugh maps, De Morgan laws... fun stuff.
    Although not always useful because the "simplified" version could make conceptually less sense.
  • 3
    Finding a way to easily solve loooooong boolean equations is literally the way to solve most of the hardest problems known to humanity.
    Not kidding, this sucker is an NP-Complete, offer referred to as "Satisfiability Problem", "SAT", or, more often, "that bitch".
Add Comment