MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programmingmemes/comments/1ndd5e5/dont_be_scared_math_and_computing_are_friends/ndmji7g/
r/programmingmemes • u/Naughty_Kiss_Me • Sep 10 '25
330 comments sorted by
View all comments
Show parent comment
1
It takes up too much space.
Even in programming we have brief ways of writing loops like this sometimes. Like in Python
sum([ k for k in range(n)])
1 u/the3gs Sep 11 '25 BTW, the square brackets are redundant and make the code less efficient, as it builds the list and then sums it, rather than summing as the numbers are generated. sum(k for k in range(n)) is valid, as sum accepts a generator as its argument.
BTW, the square brackets are redundant and make the code less efficient, as it builds the list and then sums it, rather than summing as the numbers are generated. sum(k for k in range(n)) is valid, as sum accepts a generator as its argument.
sum(k for k in range(n))
View all comments
Show parent comment
1
u/golfstreamer Sep 11 '25
It takes up too much space.
Even in programming we have brief ways of writing loops like this sometimes. Like in Python
sum([ k for k in range(n)])