in reply to Efficiency and Functions in loops

The Memoize module is the standard way to do this.