The memoize vocabulary implements a simple form of memoization, which is when a word caches results for every unique set of inputs that is supplied. Calling a memoized word with the same inputs more than once does not recalculate anything.

Memoization is useful in situations where the set of possible inputs is small, but the results are expensive to compute and should be cached. Memoized words should not have any side effects.

Defining a memoized word at parse time:

Defining a memoized word at run time:
define-memoized ( word quot effect -- )

Clearing memoized results:
reset-memoized ( word -- )