5SpeedDeasil@lemmy.world to Memes@lemmy.ml · 1 year agoRandom internet people explaining math better then math teacheri.imgur.comimagemessage-square200fedilinkarrow-up11.62Karrow-down160
arrow-up11.56Karrow-down1imageRandom internet people explaining math better then math teacheri.imgur.com5SpeedDeasil@lemmy.world to Memes@lemmy.ml · 1 year agomessage-square200fedilink
minus-squarehorni3000@feddit.delinkfedilinkarrow-up16arrow-down1·1 year agoYou can reduce this readable code into one line of confusing python list comprehension that runs 100x slower!
minus-square0xff@lemmy.worldlinkfedilinkarrow-up6·1 year 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-squareFaresh@lemmy.mllinkfedilinkarrow-up2·1 year 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.
minus-squarehglman@lemmy.mllinkfedilinkarrow-up6·1 year agoYes, the classic readability of c style for loops. How about some Haskell let numbers = [1, 2, 3, 4, 5] let sumOfNumbers = sum numbers
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))
.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.
Yes, the classic readability of c style for loops.
How about some Haskell
let numbers = [1, 2, 3, 4, 5] let sumOfNumbers = sum numbers