this post was submitted on 05 Dec 2024
226 points (93.1% liked)
Science Memes
11397 readers
239 users here now
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
- Don't throw mud. Behave like an intellectual and remember the human.
- Keep it rooted (on topic).
- No spam.
- 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
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- !reptiles and [email protected]
Physical Sciences
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
Humanities and Social Sciences
Practical and Applied Sciences
- !exercise-and [email protected]
- [email protected]
- !self [email protected]
- [email protected]
- [email protected]
- [email protected]
Memes
Miscellaneous
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I'm pretty sure that
funky()
would always return0
, as defined. I'll pseudocode that up:The
if
in your function can never be reached, without some weird manipulation of the value ofa
that breaks variable scoping in most syntaxes.I think that I see your logic but it is syntactically incorrect:
In most syntaxes, this is a conditional execution and value assignment. That is, the code in curly braces only gets executed, if the conditional evaluates as true. If the conditional evaluates as true, the code is executed, assigning the value 1 to the variable
b
.It does NOT imply that the assignment of the value 1 to the variable
b
is a conditional requiring the assignment of the value 1 to the variableb
.Remember:
=
in most programming is NOT an equality symbol but a value-assigment symbol. It would be nice if people creating the initial syntaxes used something else that is harder to confuse but they didn't.Yeah, I’m not sure what the original intent was here. If we’re missing something I’d like to know
Yes, I know, that's the point. Funky is specifically constructed to always return 0. Then we assume "if" and "if, and only if" are equivalent and by following that assumption to its logical conclusion, we deduce that funky returns 1. Therefore, our assumption was incorrect because 0≠1. It follows that "if" isn't equivalent to "if, and only if". Also, it's just a shitpost.
If reading the code as non-programming logic, that conclusion makes sense, yes. However,
if
, in most syntaxes, is a type of flow control. What it wraps has no meaning to theif
statement itself. Reading it through the lens of an interpreter/compiler makes it clear. The statement is approximately:To one not familiar with how programs are executed, it would make sense that the return value could be 1. But understanding how flow control works in programming, makes this interpretation a challenge.
I don't think you're picking up what I'm putting down. I'm not arguing that the return value can be 1, I'm well aware that it can't — I wrote the function so that it will always return 0. It only returns 1 if we make an incorrect assumption (and mix up semantics with formal logic, but that's another conversation), the incorrect assumption being "if is equivalent to if, and only if"
Sorry! I sometimes get carried away on correctness.
I mean, making an assumption and arriving to a contradiction is as correct as a proof gets.