in reply to Re: Doing "it" only once
in thread Doing "it" only once

It quickly becomes apparent that a generic solution to the general problem is a state machine, and that such a generic solution is (or could be) an interpreter of a regular language. (This is taught in (approximately) CS 440, though the principles are introduced earlier than that.)