You are viewing a single thread.
View all comments
17 points

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

permalink
report
reply
8 points

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

permalink
report
parent
reply
6 points

Yes, the classic readability of c style for loops.

How about some Haskell

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

permalink
report
parent
reply
3 points

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.

permalink
report
parent
reply

Memes

!memes@lemmy.ml

Create post

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.

Community stats

  • 8.5K

    Monthly active users

  • 13K

    Posts

  • 288K

    Comments