wasm-demo/demo/ermis-f/python_m/cur/0587

36 lines
1.0 KiB
Plaintext

From: stephan at pcrm.win.tue.nl (Stephan Houben)
Date: 23 Apr 1999 16:34:06 +0200
Subject: Suggestion for alternative to map/filter functions
References: <slrn7i10gu.2a3.hat@se-46.wpa.wtb.tue.nl> <Y90U2.19$eD1.15049@news.corridex.com>
Message-ID: <m3so9rl82p.fsf@pcrm.win.tue.nl>
X-UID: 587
"Evan Simpson" <evan at 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