I love list comprehension. Best part of the language, imo. To each their own.
- 1 Post
- 274 Comments
Weird example. 3 nested conditionals is not the typical use case for a ternary, and 2 of the 5 branches result in a pointless a=a assignment. I agree this is bad code, but it’s just as bad and hard to parss in a normal if-else structure too:
if (a>b) { if (b>c) { if (a<d) { a=c; } else { a=a; } } else { a=d; } } else { if (b<c) { a=a; } else { a=d; } }
In another situation, though, it’s perfectly readable to have a much more typical ternary use case like:
a = c > d ? c : d
And a pair of parentheses never hurt readability either:
a = (c > d) ? c : d
kryptonianCodeMonkey@lemmy.worldto News@lemmy.world•Political commentators should avoid open, outdoor venues, law enforcement expert says5·3 days agoSitting state representatives and their families were shot and killed in their homes by someone impersonating a police officer…
kryptonianCodeMonkey@lemmy.worldto Programmer Humor@lemmy.ml•i love ai in my offline foss softwares that are still in beta3·6 days agoThat’s why I asked. Shorting would involve betting the bubble will pop in a specific time frame and has no upper end to what I could lose if the bubble doesn’t pop in time. I was asking if there is any other way to bet against them that I didn’t know about. Something without that time frame and/or lower risk.
kryptonianCodeMonkey@lemmy.worldto Programmer Humor@lemmy.ml•i love ai in my offline foss softwares that are still in beta2·6 days agoYea, that’s what I figured.
kryptonianCodeMonkey@lemmy.worldto Programmer Humor@lemmy.ml•i love ai in my offline foss softwares that are still in beta14·6 days agoI’m not a big market speculator guy. Does anyone know if there is a way to bet against AI, to make money when the AI bubble pops? Not shorting.
kryptonianCodeMonkey@lemmy.worldto Programmer Humor@lemmy.ml•i love ai in my offline foss softwares that are still in beta1·6 days agodeleted by creator
kryptonianCodeMonkey@lemmy.worldto politics @lemmy.world•Trump's risque birthday doodle to Jeffrey Epstein released by House Democrats5·6 days agoI did see a similar letter like this before. Seems to have been a recreation based off the description given though. This is the actual scan of the letter, the original.
kryptonianCodeMonkey@lemmy.worldto News@lemmy.world•Treasury Secretary Bessent warns of massive refunds if the Supreme Court voids Trump tariffs7·7 days agoThe only solution is revolution.The only verdict is vengeance. A vendetta.FTFY.
kryptonianCodeMonkey@lemmy.worldto politics @lemmy.world•‘What the hell?’ House Speaker confuses White House with claim Trump was an FBI snitch19·8 days agoIf that was remotely true, Trump would have been claiming responsibility for Epstein’s arrest from day 1. It’s simply not true in the slightest. It’s a complete, wholecloth fabrication. A 100% lie.
And that’s why you’ve got no chance as a movement. And you couldn’t create anything sustainable even if you did. Congrats.
Marxist: Let me mock one of my closest ideological allies. That will help bring about revolution.
Democratic Socialist: The fuck did I do to you, bro?
Damn you’re right. I bet i could come up with a bullshit bitwise operator solution too
Basically, “why cross the street when you can circle the block 4 times while walking backwards and end up at the same spot”?
Works for code too
import math def multiply_bad(a:int, b:int) -> int: return a*b def multiply_better(a:int, b:int) -> int: return (-1 if a<0 else 1)*(-1 if b<0 else 1)*int(math.sqrt(a*a*b*b)) def multiply_perfect(a:int, b:int) -> int: product = 0 negative = False if a < 0: a = -1*a negative = not negative if b < 0: b = -1*b negative = not negative for i in range(a): for j in range(b): product += 1 if negative: return -1*product return product
Right? It’s in a stupid place in each bathroom in my house. Whoever installed them had never heard of ergonomics.I just remove the roll entirely, set it on the sink and put it back when I’m done.
kryptonianCodeMonkey@lemmy.worldto News@lemmy.world•Crime Festers in Republican States While Their Troops Patrol Washington13·12 days agoMake sure we’re just pointing out the hypocrisy and lies, not advocating for more misuse of the national guard and federal agents than we already have.
“You ever notice how _____ people do [insert common, innocuous, rational behavior]…”
In what language is that valid syntax?