Function composition

In the Functions currying recipe, we discovered a neat way of transforming a function to extract new functions from it. In this recipe, we are going to work on implementing the opposite transformation. It would be useful to have the option to merge a number of existing functions' declarations and define a new function from them. This is a common functional programming pattern called functions composition. Kotlin doesn't provide function composition mechanism out of the box. However, thanks to the extended built-in support for operations on functional types, we are able to implement a reusable mechanism for the composition manually.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.255.126