The way you play with coderefs and for loops is vaguely reminiscent of map.. I'm not sure what I want to get at, since I don't have a deep CS theory background, but my intuition tells me you're doing something that could be generalized better in the functional programming paradigma.