1671
submitted 1 year ago by 5SpeedDeasil@lemmy.world to c/memes@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] horni3000@feddit.de 17 points 1 year ago

You can reduce this readable code into one line of confusing python list comprehension that runs 100x slower!

[-] 0xff@lemmy.world 8 points 1 year ago

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)).

[-] hglman@lemmy.ml 6 points 1 year ago

Yes, the classic readability of c style for loops.

How about some Haskell

let numbers = [1, 2, 3, 4, 5] let sumOfNumbers = sum numbers

[-] Faresh@lemmy.ml 3 points 1 year ago

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.

this post was submitted on 16 Jul 2023
1671 points (96.5% liked)

Memes

45778 readers
1996 users here now

Rules:

  1. Be civil and nice.
  2. Try not to excessively repost, as a rule of thumb, wait at least 2 months to do it if you have to.

founded 5 years ago
MODERATORS