WHAT'S IN THIS CHAPTER?
Understanding pipelining operators
Understanding composition operators
Getting started with pipelining function composition
Using advanced function composition
What is it about functional languages that make them so powerful for data structure processing? One answer to this is composability. Instead of being a built-in language construct such as
foreach, functional abstractions like
reduce are themselves functions. They are first-class language citizens, no different than any function you might write yourself. This means that they are much more flexible because they can be built one argument at a time, passed around, and even combined with other functions.
Out of this composability comes a data-oriented programming technique called pipelining. In pipelining, functions are combined or chained together with special operators. This allows you to pass the results of one function directly and unambiguously into the next. In this way, programs can be constructed as a series of discrete data transformations. As you will see, this approach produces short and expressive data processing programs.
When writing code using composition and pipelining, there are four primary operators. Each of these is a combination of two ideas, performing an operation to the left or right and either pipelining data or composing functions. When combined, they provide a powerful set of tools that allow you to ...