Personally I am not a big fan of injecting complex lambda behavior into the heart of a loop. It makes it hard to modify one without breaking the other or even knowing if the other will malbehave.
If you like, I could suggest an alternative structure. If you protest, it is also fine with me.