I'm in a situation where I need to explain lambda expressions to a colleague. He's well-educated, with some programming experience, and my first time showing him lambda expressions seemed to go well. What I'm not explaining well to him is the idea that you can nest lambda expressions inside each other.
I use lambdas all the time, and feel like this should be easy to explain to him, but I'm having trouble coming up with an example on the spot, so I'll just pass his question on to all of you:
Why would anyone ever need to nest lambda expressions?
I'm looking for an example sort of like this:
x.f(y => y.g(z => y+z))
where one lambda expression is nested inside another, where the innermost bit of code (
y+z in this example) makes use of both lambda input parameters.
We're using C#, but the language isn't what matters, just a situation where you'd want nested lambdas in a language that isn't mostly lambda calculus.