@5SpeedDeasil@lemmy.world to Memes@lemmy.ml • 2 years agoRandom internet people explaining math better then math teacheri.imgur.comimagemessage-square205fedilinkarrow-up11.65Karrow-down160
arrow-up11.59Karrow-down1imageRandom internet people explaining math better then math teacheri.imgur.com@5SpeedDeasil@lemmy.world to Memes@lemmy.ml • 2 years agomessage-square205fedilink
minus-square@horni3000@feddit.delinkfedilink16•2 years agoYou can reduce this readable code into one line of confusing python list comprehension that runs 100x slower!
minus-square@0xff@lemmy.worldlinkfedilink7•2 years agoWhat’s wrong with list comprehensions? Do I just have Stockholm Syndrome at this point? I would skip the square brackets and just use a generator expression: sum(3*n for n in range(5)).
minus-square@hglman@lemmy.mllinkfedilink6•2 years agoYes, the classic readability of c style for loops. How about some Haskell let numbers = [1, 2, 3, 4, 5] let sumOfNumbers = sum numbers
minus-square@Faresh@lemmy.mllinkfedilink2•2 years agoI don’t think you can use python list comprehensions in this case, since you don’t want a new list, but rather reduce it to a single value.
You can reduce this readable code into one line of confusing python list comprehension that runs 100x slower!
What’s wrong with list comprehensions? Do I just have Stockholm Syndrome at this point?
I would skip the square brackets and just use a generator expression:
sum(3*n for n in range(5))
.Yes, the classic readability of c style for loops.
How about some Haskell
let numbers = [1, 2, 3, 4, 5] let sumOfNumbers = sum numbers
I don’t think you can use python list comprehensions in this case, since you don’t want a new list, but rather reduce it to a single value.