4 ms·
If you were writing code, I would argue against using De Morgan's laws just because you can. You're saving a few characters to make the code less obvious. Plea
by zumu 9y ago
If you were writing code, I would argue against using De Morgan's laws just because you can.
You're saving a few characters to make the code less obvious. Please correct me if there's some other benefit.
- justinpombrio 9y agoUsually after a mathematical simplification like this, you can find a direct explanation for it. In this case you can reason: If two appointments conflict, that means that there is a time when they are both active. Thus each of their end times are after both of their start times. Of course, each appointment ends after it started, so that just leaves that each appointment ends after the other started. So if the appointments are a to b and c to d, then they conflict iff b > c and d > a. (I've corrected bumbledraven's mistake of a > d vs. d > a.)
- qb45 9y agoI would say, if the transformation makes the code and the reasoning behind it simpler then do it. Otherwise, know that any decent optimizing compiler can do this trick by itself so what you write only influences readability.