A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-April/072628.html below:

[Python-Dev] functools additions

[Python-Dev] functools additionsBJörn Lindqvist bjourne at gmail.com
Mon Apr 16 00:36:42 CEST 2007
> def cat(x): return x
>
> def multimap(func, s, n=2):
>     assert n > 0, "n must be positive"
>     return (map(func, seq)
>             if n == 1 else
>             map(lambda x: multimap(func, x, n-1),
>                 seq))
>
> def multifilter(func, s, n=2):
>     return multimap(lambda x: filter(func, x), s, n-1)
>
> def multireduce(func, s, n=2):
>     return multimap(lambda x: reduce(func, x), s, n-1)
>
> class nullfunc(object):
>     def __call__(self, *a, **k): return self
>     def __getattr(self, name): return getattr(None, name)

Could you describe what these functions do? Preferably with examples
that demonstrates that they are useful.

-- 
mvh Björn
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4