4 ms·
Yes, lots of them are available. But I also would like to be able to call .sum() on my iterable at the end of a chain, instead of having to mentally unwrap sum(
by matsemann 5y ago
Yes, lots of them are available. But I also would like to be able to call .sum() on my iterable at the end of a chain, instead of having to mentally unwrap sum(map(filter(filter(map(...))))
- weatherlight 5y agoI strongly dislike python, I often wonder if it would have been as popular if Guido didn't work at Google early on.
- int_19h 5y agoGuido joined Google in 2005, and it was already plenty popular by then.
- glaucon 5y agoFWIW Python was fourteen years old when GVR joined the Borg. That doesn't address how popular it was but I think it's reasonable to say it was well established.
- tored 5y agoWhy do you strongly dislike Python? Language design, standard library, community, leadership?
- weatherlight 5y agoMostly language design. Guido van Rossum doesn't appreciate FP and he really genuinely doesn't understand it. That's not to say he's dumb or not a nice guy or anything. It's just not his area. And this is reflected in the language. His attitude of you have to be "really smart" to understand FP is a mistake. https://developers.slashdot.org/story/13/08/25/2115204/interviews-guido-van-rossum-answers-your-questions https://developers.slashdot.org/story/13/08/25/2115204/inter... https://blog.finxter.com/about-guidos-fate-of-reduce-in-python-3000/ https://blog.finxter.com/about-guidos-fate-of-reduce-in-pyth...
- int_19h 5y agoBut you only ever need to unwrap one sum(). And with sequence comprehensions, what you get instead is sum(... for ... if ... for ... if ...) - I don't think that's improved by rewriting it as (...).sum().
- XorNot 5y agoThere's a not unreasonable position implicit in Python's way that the "most significant" operation should be most visible. The problem with filter chaining is the final assignment and the actual value are separated by the rest of the chain. i.e. x = strList.filter(parseInt).sum() doesn't tell me what type x is till I read the whole line. Whereas: x = sum( parseInt(v) for v in strList ) tells me as quickly as possible that I'm dealing with a single value output that will be a sum.
- aasasd 5y agoI bet a Clojure-style ‘threading’ arrow function can be easily done in Python. arrow(my_list [map args] [filter args] [filter args] [map args] [sum]) For cases when function argument positions differ, you'll need some special var in your module to signal where to inject the list. arrow(my_list [map map_func arrow.list_here]) Won't be surprised if something like this already exists, but I can't think of keywords to search for that aren't too generic.
- dragonwriter 5y ago> But I also would like to be able to call .sum() on my iterable at the end of a chain Yeah, one thing I like about Ruby over Python is the fluent code th former allows of that style. People talk about Guido not liking functional style, but that explains comprehensions over map/filter, but not function-sum() over method .sum().