[Python-Dev] a different kind of reduce...
Samuele Pedroni
pedronis at strakt.com
Tue Nov 1 22:00:20 CET 2005
Reinhold Birkenfeld wrote:
> Raymond Hettinger wrote:
>>>[Martin Blais]
>>>>>>I'm always--literally every time-- looking for a more functional
>>>>form,
>>>>>>something that would be like this:
>>>>>>>> # apply dirname() 3 times on its results, initializing with p
>>>> ... = repapply(dirname, 3, p)
>>>>[Greg Ewing]
>>>>>Maybe ** should be defined for functions so that you
>>>could do things like
>>>>>> up3levels = dirname ** 3
>>>>Hmm, using the function's own namespace is an interesting idea. It
>>might also be a good place to put other functionals:
>>>> results = f.map(data)
>> newf = f.partial(somearg)
>>> And we have solved the "map, filter and reduce are going away! Let's all
> weep together" problem with one strike!
not really, those right now work with any callable,
>>> class C:
... def __call__(self, x):
... return 2*x
...
>>> map(C(), [1,2,3])
[2, 4, 6]
that's why attaching functionaliy as methods is not always the best
solution.
regards.
More information about the Python-Dev
mailing list