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/2009-August/091163.html below:

[Python-Dev] functools.compose to chain functions together

[Python-Dev] functools.compose to chain functions togetherXavier Morel catch-all at masklinn.net
Fri Aug 14 20:58:22 CEST 2009
On 14 Aug 2009, at 20:39 , Jason R. Coombs wrote:
> I've heard it said that Python is not a functional language, but if  
> that
> were really the case, then functools would not exist. In addition to  
> the
> example described above, I've had multiple occasions where having a  
> general
> purpose function composition function would have simplified the
> implementation by providing a basic functional construct.

It's not like a basic variable-arity composition function is hard to  
implement though, it's basically:

     def compose(*funcs):
         return reduce(lambda f1, f2:
                           lambda v:
                               f1(f2(v)),
                       funcs)

it'll turn compose(a, b, c, d)(value) into a(b(c(d(value))))
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