map/filter/reduce/lambda opinions and background unscientificmini-survey
Christopher Subich
spam.csubich+block at block.subich.spam.com
Mon Jul 4 13:50:57 EDT 2005
Carl Banks wrote:
> I suspect you're misunderstanding what I mean by heavily functional.
<snip>
> Heavily functional programming is a different mindset altogether. In
> heavily functional programming, things like maps and filters and
> function applications are actually what you're thinking about. map
> isn't an indirect way to do a for loop; it's a direct way to do a map.
That's true; I'm more comfortable with procedural programming in
general, but I had a few classes that used LISP and understand what
you're talking about.
That said, Python itself is mostly a procedural language, with the
functional tools really being bolted on[1]. When we're talking about
Py3K, I think we're really talking about a redesign and rethink of
pretty much the entire language -- with list and generator
comprehensions, for procedural programming the need for map and lambda
goes away. Reduce isn't directly replaced, of course, but a for-loop
implementation (for procedural programming) is clearer, more powerful,
more explicit, and possibly faster.
That said, I very much like the idea of putting map and filter in a
functional module. For applications like functional-style programming
where map/etc are clearer, that keeps them in the library for efficient
use, yet it leaves the native language with OO(g)WTDI [Only One (good)
Way to Do It].
[1] -- lambda excepted. I think it's kind of cute, in a baby-mammal
kind of way.
More information about the Python-list
mailing list