concept lambda in category functional programming

This is an excerpt from Manning's book Functional Programming in C++.
Fortunately, C++ has lambdas, which are syntactic sugar for creating anonymous (unnamed) function objects. Lambdas allow you to create function objects inline—at the place where you want to use them—instead of outside the function you’re currently writing. Let’s see this in an example from earlier: you have a group of people, and you want to collect only females from that group (see figure 3.3).
Figure 3.3 Getting all females from a group of people. You’ve been using a predicate called
is_female
, which is a non-member function for this. Now you’re going to do the same with a lambda.![]()
One thing worth noting is that the call operator of lambdas is constant by default (contrary to the other parts of the language, where you need to explicitly specify that something is
const
). If you want to change the value of the captured variables, when they’re captured by value and not by reference, you’ll need to declare the lambda asmutable
. In the following example, you use thestd::for_each
algorithm to write all words beginning with an uppercase letter, and you use thecount
variable to count the number of words you wrote. This is sometimes useful for debugging, but mutable lambdas should be avoided. Obviously, there are better ways to do this, but the point here is to demonstrate how mutable lambdas work.Listing 3.5 Creating a mutable lambda
int count = 0; std::vector<std::string> words{"An", "ancient", "pond"}; std::for_each(words.cbegin(), words.cend(), [count] #1 (const std::string& word) mutable #2 { if (isupper(word[0])) { std::cout << word << " " << count <<std::endl; count++; } } ); #1 You’re capturing “count” by value; all changes to it are localized and visible only from the lambda. #2 mutable comes after the argument list and tells the compiler that the call operator on this lambda shouldn’t be const.

This is an excerpt from Manning's book Functional Programming in Java: How functional techniques improve your Java programs.
Note that the lambda is the only place where Java allows you to use the (x, y) notation for tuples. Unfortunately, it can’t be used in any other cases, such as returning a tuple from a function.
The second problem you have is that functions defined using anonymous classes are cumbersome to use in coding. If you’re using Java 5 to 7, you’re out of luck, because there’s no other way to go. Fortunately, Java 8 introduced lambdas.