Created
February 11, 2025 20:31
-
-
Save scottcreynolds/6c1dcb0d323f2c16e6d8463f24f265ae to your computer and use it in GitHub Desktop.
Logic Bullshit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in logic notation | |
# a -> b is "if a then b" | |
# so in programming: | |
a = false | |
b = true | |
if a | |
puts "a true" | |
if b | |
puts "b true" | |
end | |
end | |
# since a == false, no output. essentially "if a" gets | |
# executed and short circuits, no "then b". b is irrelevant | |
# in logic, the whole statement gets evaluated and truth isn't derived | |
# from the truth of the first evaluated term in a sequence, so | |
# a = false, b = true, if a then b = true | |
# a = false, b = false, if a then b = true | |
# a = true, b = true, if a then b = true | |
# a = true, b = false, if a then b = false | |
# "if a then b" is only false if a is true and b is false because the english | |
# representation is like "it follows that if a then also b" so equally true is "if not a then still could be b" | |
# or "if not a then definitely not b" but never "if a then not b" | |
# which is easy enough to parse out of course but programming brain wants to be like | |
# "oh, not a? well fuck b who cares?" | |
# (a&b) follows what you'd expect for (a && b) i.e. both true or statement false | |
# (avb) follows (a || b) i.e. any true value makes it true | |
# BUT when you're used to using that short circuit logic to do things like | |
c = a || b | |
# then you're only used to considering the first term's truthiness because the | |
# second term is taken as a value for assignment, so the truthiness of the full statement doesn't matter | |
# again, easy enough to parse but programming zug brain is like "a or b but only actually care about a" | |
# a <--> b is a whole other dumb thing because it's true only if both are true or both are false | |
# so it's all like JUST different enough to fuck you up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment