Generalization of memoizer