functional programming with map()
Grant Edwards
grante at visi.com
Mon Feb 25 14:16:32 EST 2002
In article <slrna7l176.3al.quinn at vomit.ugcs.caltech.edu>, Quinn Dunkan wrote:
> On Sun, 24 Feb 2002 19:34:34 -0800, David Eppstein <eppstein at ics.uci.edu> wrote:
>>In article <a5cb54$27c2$1 at agate.berkeley.edu>,
>> Daniel Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:
>>
>>> : But what is the functional equvalent of:
>>>
>>> : for x in items:
>>> : x.f()
>
> There really is no functional equivalent of that, because it's not a functional
> concept. If your function doesn't have any side-effects, calling the function
> only to throw away its value does nothing but suck up CPU time.
>
> If you're calling the method for its side-effects, I'd write:
>
> for x in items:
> x.f()
>
>>I'd prefer
>>[x.f() for x in items]
>>
>>It's not functional syntax, but so what?
>
> Sure it is.
Methinks there are two definitions of "functional" at work here:
1) The traditional CS "no side-effects" definition.
2) Something that looks like a function call.
?
--
Grant Edwards grante Yow! Yow! I forgot my
at PAIL!!
visi.com
More information about the Python-list
mailing list