4 ms·
The Python community has frowned on functional programming, reduce isn't in basic Python anymore, and they almost took out lambda: http://www.artima.com/weblogs
by steveklabnik 16y ago
The Python community has frowned on functional programming, reduce isn't in basic Python anymore, and they almost took out lambda: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 http://www.artima.com/weblogs/viewpost.jsp?thread=98196
- RyanMcGreal 16y agoStrange that they took out reduce() but not map() and filter(), which you can easily replicate with list comprehensions.
- steveklabnik 16y agoYeah. The argument is based on reduce not being clear and easy to understand, which is frustrating to those of us who actually find map/reduce/filter to be more clear, not less.
- ubernostrum 16y agoreduce isn't in basic Python anymore It's in a module in the standard library, a module which contains a bunch of tools for working with higher-order functions. Or, in other words, if you've got a Python 3.x installed, you've got a reduce function available. The only difference is that it's no longer in the default global namespace (map and filter still are, of course). This matches up pretty cleanly with my actual experience of writing Python; I've written a hell of a lot of Python code these past 6-7 years and so far as I can recall I've never used reduce. (and if you want to get picky about this, keep in mind how much of Haskell requires import statements to get at -- moving less-commonly-used stuff into standard modules is not a bad thing at all)