Composite design

The common mathematical notation for a composite function looks as follows:

 

The idea is that we can define a new function, , that combines two other functions,  and .

Python's multiple-line definition of a composition function can be done through the following code:

@f_deco
def g(x):
    something  

The resulting function can be essentially ...

Get Functional Python Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.