Live data from Hacker News

Clearer Conditionals using De Morgan's Laws

robots.thoughtbot.com

61–70 of 82 posts

Re: Clearer Conditionals using De Morgan's Laws

#61

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 =…

One of the legitimate use cases for goto is for complex error handling. I'm not sure why it needs to be unacceptable across the board.

Re: Clearer Conditionals using De Morgan's Laws

#62
post #23
post #13

If 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…

Yeah, K-maps were part of the circuit design course we had to take for our undergrad CS degree.

Re: Clearer Conditionals using De Morgan's Laws

#63
post #24

Old 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.

Those pranksters just don't understand the left distributive law of foodstuffs.

Re: Clearer Conditionals using De Morgan's Laws

#64
post #45
post #39

Earlier 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.

The article was trivial. I upvoted because I learned about Karnaugh maps in the discussion.

Re: Clearer Conditionals using De Morgan's Laws

#65
post #23
post #13

If 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…

yup, zvi-kohavi is a good text...

Re: Clearer Conditionals using De Morgan's Laws

#66
post #13

If 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

#67
post #13

If 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)

I am at a highly ranked school right now and they are not covered in any CS class. Computer Engineering majors learn them in their introductory course.

Re: Clearer Conditionals using De Morgan's Laws

#68
post #45

Earlier 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.

Do tell more about how to use github to order vegan lunches.
Post reply on HN