Programmers have long looked for solutions to write less code that does more things. Functional programming proposes one solution—build functions by deriving from other functions.
We've already seen this in action in the previous examples. Since increment is a particular case of addition, we can derive it from our addition function:
auto add = [](const auto first, const auto second) { return first + second; };
auto increment = bind(add, _1, 1);
TEST_CASE("Increments"){
CHECK_EQ(43, increment(42));
}
How does this help us? Well, imagine your customer comes in one day and tells you we want to use another type of addition. Imagine having to search for + and ++ everywhere in your code and figuring out ways to implement the new behavior.
Instead, with our add and increment functions, and a bit of template...