doc.txt

Memoize

_Memoize_
_memoize_

This collection provides one file:

 _memoize.ss_: macros for defining memoized procedures

This library provides a syntax for defining memoized procedures.

CAVEAT: This library is not thread-safe. I'll work on that.

======================================================================

> (memo-lambda (args ...) body0 body1 ...)
> (memo-lambda (args ... . rest) body0 body1 ...)
> (memo-lambda args body0 body1 ...)

A syntax for defining memoized anonymous procedures. Arguments are mapped to
their results by storing them in a local hash-table (using eq? to compare
arguments for equality).

Simpler cases are optimized: the zero-argument variant simply saves its result
in a local variable, and the one-argument variant maps its argument to its
result in a local hash table. The multiple-argument variant maps its entire list
of arguments to its result in a local hash table, attempting to reduce search
time by hashing on the bitwise-xor of the hashcodes of its arguments.

> (memo-lambda* (args ...) body0 body1 ...)
> (memo-lambda* (args ... . rest) body0 body1 ...)
> (memo-lambda* args body0 body1 ...)

Same as `memo-lambda', but uses equal? to compare arguments for equality when
storing them in the memoization table.

> (define/memo (name args ...) body0 body1 ...)
> (define/memo (name args ... . rest) body0 body1 ...)

A syntax corresponding to the standard Scheme procedure definition
shorthand. This macro expands to a (define (name args ...) etc.) form, so it can
be used in any context that accepts such procedure definitions. In particular,
this means it can be used to define memoized methods with the mzscheme class
library.

> (define/memo* (name args ...) body0 body1 ...)
> (define/memo* (name args ... . rest) body0 body1 ...)

Same as `define/memo', but uses equal? to compare arguments for equality when
storing them in the memoization table.