Common Lisp Package: ORG.TFEB.HAX.MEMOIZE

README:

FUNCTION

Public

CLEAR-MEMOIZED-FUNCTION (FN-NAME)

Clear memoized results for FN-NAME

CLEAR-MEMOIZED-FUNCTIONS

Clear memoized results for all functions

FUNCTION-MEMOIZED-P (FN-NAME)

Is FN-NAME memoized?

MEMOIZE-FUNCTION (FN-NAME &KEY (KEY #'FIRST) (TEST #'EQL))

Memoize FN-NAME, a symbol, causing its results to be stashed. KEY is a function which is given the arglist of FN-NAME, and should return a key to hash on for memoizing. TEST is a function which the test for the ashtable. See Norvig P269-275. Note this function may not work on self-recursive functions because the compiler can optimize away self-calls in various ways. DEF-MEMOIZED-FUNCTION should work for those cases as it is careful to ensure the function can not be inlined like this.

UNMEMOIZE-FUNCTION (FN-NAME)

Remove memoization for FN-NAME

UNMEMOIZE-FUNCTIONS

Unmemoize all functions

Private

Undocumented

MAKE-MEMO (FN KEY TEST)

MACRO

Public

DEF-MEMOIZED-FUNCTION (FNSPEC ARGS &BODY BOD)

Define a memoized function. FNSPEC is either the name of the function, or a list suitable as an arglist for MEMOIZE-FUNCTION. ARGS & BOD are passed off to DEFUN. This will declare FNSPEC NOTINLINE, which may be necessary to prevent good compilers optimizing away self calls & stuff like that.

MEMOIZED-LABELS ((&REST LABDEFS) &BODY BOD)

A version of LABELS that memoizes the local functions. See MEMOIZE-FUNCTION and DEF-MEMOIZED-FUNCTION. If code that uses this is compiled (either by COMPILE or COMPILE-FILE, then the table of memoized results will be unique, if interpreted then a new table may be generated for each use. The function `names' are generalised in the same way as for DEF-MEMOIZED-FUNCTION.

VARIABLE

Private

Undocumented

*MEMOIZED-FUNCTIONS*