This is going to reveal my ignorance, but why can't you evaluate `f` a single time outside of this loop?