if statement == false

2 years ago by tatterdemalion to c/science_memes

load all comments
raoul 55 points 2 years ago

The boolean operator 'If and only if' do not have a relation with the program instruction 'if'.

The programatic 'if' is a jump, not a boolean operator. It do not have truth table.

In logic:, if and iff can be seen like functions taking two booleans and returning a boolean

  • 'if a then b' (noted a -> b): return true if a is false or b is true. Example: 'if I eat pizza then I fart' This is true even if I fart all the time (if b is true, we do not care about the value of a) as long as I fart when eating pizza (if a is true, b must be also true)

  • 'a <-> b' is equivalent to 'a -> b and b -> a': the two should be true at the same time. I can only fart will eating pizza and cannot fart otherwise.

path: 0 13818133, hotness: undefined, score: 55, children: 5
Hoimo 5 points 2 years ago

So in programming, you'd write 'if' as:
not pizza or fart where the farting is irrelevant until the pizza is involved.

While 'iff' would be:
pizza equals fart where pizza means fart and no pizza means no fart.

I actually wrote iff as (not pizza and not fart) or (pizza and fart) before, and I'm pretty sure that's the way I wrote an iff in production code in the past, but your comment made me realize that "they should be true at the same time" can be tested really easily with equality.

path: 0 13818133 13826518, hotness: undefined, score: 5, children: 3
Venator 1 point 2 years ago

I don't love the pizza fart variable naming convention, but it's better than foobar and I don't have a better suggestion 😅

path: 0 13818133 13826518 13857924, hotness: undefined, score: 1, children: 0
captain_aggravated 1 point 2 years ago

If not pizza and not fart: pass

path: 0 13818133 13826518 13839766, hotness: undefined, score: 1, children: 1
Ephera 1 point 2 years ago
path: 0 13818133 13822263, hotness: undefined, score: 1, children: 0
science_memes
science_memes

@mander.xyz

login for more options
20546
7336
9330

Welcome to c/science_memes @ Mander.xyz!

A place for majestic STEMLORD peacocking, as well as memes about the realities of working in a lab.



Rules

  1. Don't throw mud. Behave like an intellectual and remember the human.
  2. Keep it rooted (on topic).
  3. No spam.
  4. Infographics welcome, get schooled.

This is a science community. We use the Dawkins definition of meme.



Research Committee

Other Mander Communities

Science and Research

Biology and Life Sciences

Physical Sciences

Humanities and Social Sciences

Practical and Applied Sciences

Memes

Miscellaneous

go to feed...