Earlier quoted context omitted.
Except where writing negative conditionals are clearer. For example turning: if(a) { if(b) { if (c) { // Do something. } } } Into: if(!a) { } elseif(!b) { } elseif(!c) { } else { // Do something. }
Interestingly I've been going back and forth on this lately. I have been playing around with SD cards on the STM32F4 and a typical SD Card transaction consists of 3 to 10 commands which, if any one fails, the transaction fails. I'm currently using negative conditionals of the form "Not Error" (the Error test is an affirmative, and so that seems ok to me) A typical sequence is like the one to set the bus width. err =…
Clearer Conditionals using De Morgan's Laws
61–70 of 82 posts
Re: Clearer Conditionals using De Morgan's Laws
#62If you want to get good at clarifying conditionals, take an electronics class and revel in the Karnaugh maps.
No need for a full blown electronics class. This subject falls under Switching Theory and can be covered thoroughly in the first (and often a single) semester. Starting with elementary set theory and boolean algebra, you go into the combinatorial logic (that covers De Morgan and Karnaugh), and finish with finite state machines (automata). There are very few requisites too. Some high schools and trade schools teach th…
Re: Clearer Conditionals using De Morgan's Laws
#63Old CS students' prank: improving the "no food and drink" sign unsurprisingly often found in labs by scribbling "no (food && drink) == (no food || no drink)" on it.
Re: Clearer Conditionals using De Morgan's Laws
#64Earlier quoted context omitted.
The article title was clearer conditionals using DeMorgan's Law - to that end, the article illustrated how to move to that step for cleaner code through first applying the law.
Yes, and the other thing I find baffling is that a trivial post talking about something that would be covered in the first part of any baby logic course---before you even get to quantifiers!---is currently ranked as high as it is.
Re: Clearer Conditionals using De Morgan's Laws
#65If you want to get good at clarifying conditionals, take an electronics class and revel in the Karnaugh maps.
No need for a full blown electronics class. This subject falls under Switching Theory and can be covered thoroughly in the first (and often a single) semester. Starting with elementary set theory and boolean algebra, you go into the combinatorial logic (that covers De Morgan and Karnaugh), and finish with finite state machines (automata). There are very few requisites too. Some high schools and trade schools teach th…
Re: Clearer Conditionals using De Morgan's Laws
#66If you want to get good at clarifying conditionals, take an electronics class and revel in the Karnaugh maps.
Re: Clearer Conditionals using De Morgan's Laws
#67If you want to get good at clarifying conditionals, take an electronics class and revel in the Karnaugh maps.
They were covered when I took my first CS math class (discrete math) - I'd imagine they are still part of the standard basic CS core (that was 24 years ago so it might have changed)
Re: Clearer Conditionals using De Morgan's Laws
#68Earlier quoted context omitted.
Yes, and the other thing I find baffling is that a trivial post talking about something that would be covered in the first part of any baby logic course---before you even get to quantifiers!---is currently ranked as high as it is.
Math is hard, let's discuss what new blah.js is there, or how that new company abandoned managers and uses github to order vegan lunches.
Re: Clearer Conditionals using De Morgan's Laws
#69 eat_gruel unless has_parents?
puts "Please sir, I want some more" if shortest_straw?