Building pipelines
Before constructing pipelines, let’s briefly recap two key concepts from the previous chapter: currying and partial application. These techniques are fundamental to creating flexible, reusable function components that serve as excellent pipeline building blocks.
Currying, as we learned, transforms a function that takes multiple arguments into a sequence of functions, each accepting a single argument. Here’s an example:
Func<int, int, int> add = (a, b) => a + b; Func<int, Func<int, int>> curriedAdd = a => b => a + b;
Partial application, on the other hand, involves fixing a number of arguments to a function, producing another function with fewer parameters:
Func<int, int, int> multiply = (a, b) => a * b; Func<int, int> triple = x => multiply(3, x);
These concepts naturally lead on to pipeline construction. By currying functions or partially applying them, we create specialized, single-purpose...