When I tried adding an inner function that was not anonymous, that didn't help much.

That may be an argument that, in real applications, you want to use a lower-level function than this. But I think the higher-level function is nice to have.