6.3.90.900
7.5 mischief/memoize: Memoized Functions
(require mischief/memoize) | package: mischief-dev |
syntax
(define/memoize (name . kw-formals) body ...+)
syntax
(lambda/memoize kw-formals body ...+)
syntax
(case-lambda/memoize [formals body ...+] ...)
syntax
(let/memoize loop-id {[x e] ...} body ...+)
Variants of define (for functions), lambda,
case-lambda, and (named) let that produce memoized
functions.
procedure
(memoize-procedure proc) → procedure?
proc : procedure?
Produces a memoized version of proc.
procedure
(call/memoize memo proc arg-or-keyword-arg ...) → any memo : memo-table? proc : procedure? arg-or-keyword-arg : any/c
If the sequence of positional and keyword arguments has an entry in
memo, produces the stored result. Otherwise, passes the arguments to
proc and records the result in memo before returning (or
raising) it.
If the sequence of keys has an entry in memo, produces the
stored result. Otherwise, calls proc and records the result in
memo before returning (or raising) it.
procedure
(memo-table? x) → boolean?
x : any/c
Recognizes memoization tables.
procedure
Creates a fresh memoization table.
procedure
(clear-memo-table! memo) → void?
memo : memo-table?
Erases the contents of memo.