Composing
Composing is quite similar to pipelining, but has its roots in mathematical theory. The concept of composition is simply—a sequence of function calls, in which the output of one function is the input for the next one—but the order is reversed from the one in pipelining. So, if you have a series of functions, from left to right, when pipelining, the first function of the series to be applied is the leftmost one, but when you use composition, you start with the rightmost one.
Let's investigate this a bit more. When you define the composition of, say, three functions as (f∘ g∘ h), and apply this composition to x, this is equivalent to writing f(g(h(x))). It's important to note that, as with pipelining, the arity of the first function ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access