4 ms·
Thanks! That looks equivalent to python without comprehensions. As far as I can tell the difference in the expressiveness of `map/filter/reduce` is mainly abo
by maksimum 8y ago
Thanks!
That looks equivalent to python without comprehensions.
As far as I can tell the difference in the expressiveness of `map/filter/reduce` is mainly about whether you like or don't like comprehensions. Do you have any examples where you believe ruby has cleaner syntax?
- dragonwriter 8y ago> As far as I can tell the difference in the expressiveness of `map/filter/reduce` is mainly about whether you like or don't like comprehensions. Comprehensions don't replace reduce, they are equivalent to a combination of map, filter, and flat_map. The difference is not just about comprehensions, since map/filter/reduce, and friends, in Python are functions, where in Ruby they are methods; so in Python when you can't do it all with comprehensions (reduce, zip, etc.), it's either imperative loops or functional notation (inside-out), while Ruby uses method call notation, which results in operations reading in the order of application.
- maksimum 8y agoGreat clarification. You're right, reduce was a typo. I definitely like how method call notations can be read left-to-right rather than inside out. Now I'm curious why python developers decided not to add these 'transformation methods' to all Iterables.