Mailing List Archive

Suggestion for alternative to map/filter functions
Hello all,

While reading the tutorial, I noticed that Python has map and filter
functions. In our language we also had them, but they were replaced by
another language construct.
Unfortunately, I don't have time and experience enough to put this in
python myself, but if people are interested in it, I can provide details.


Albert
---
Look ma, windows without Windows !!
Suggestion for alternative to map/filter functions [ In reply to ]
"Evan Simpson" <evan@tokenexchange.com> writes:

> What language are we speaking of here? I'm sure somebody here would be
> interested in a description of this mystery construct, if it's sufficiently
> elegant. Sorry, I find your post amusingly cryptic.

My guess would be that he's talking about list comprehension.
(Did I spell that last word correctly.)

That looks something like this (pseudo Haskell/Python alert):

strlist = [str(i) | i <- intlist ]

,which is supposed to do the same thing as strlist = map(str,intlist).
To filter out all negative numbers:

strlist = [str(i) | i <- intlist | i >= 0]

You see, mapping and filtering in one fellow swoop! Cool!
Sorts of, at least.

Greetings,

Stephan
Suggestion for alternative to map/filter functions [ In reply to ]
Albert Hofkamp wrote:
> Hello all,

Hi, Albert!

> While reading the tutorial, I noticed that Python has map and filter
> functions. In our language we also had them, but they were replaced by
> another language construct.
> Unfortunately, I don't have time and experience enough to put this in
> python myself, but if people are interested in it, I can provide details.

What language are we speaking of here? I'm sure somebody here would be
interested in a description of this mystery construct, if it's sufficiently
elegant. Sorry, I find your post amusingly cryptic.

It should be mentioned that map and filter (and especially their buddy
lambda) are lonely immigrants from the land of functional programming, and
are regarded with suspicion by many of the natives.

a-construct-proposed-by-Fermat-in-the-margin?-ly y'rs
Evan
Suggestion for alternative to map/filter functions [ In reply to ]
Note that there was a long & highly developed thread about Pythonic list
comprehensions last August. Guido didn't hate the idea <wink>.

high-praise-indeed-ly y'rs - tim