The defmemo Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The defmemo Reference Manual

This is the defmemo Reference Manual, version 1.5, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 04:25:37 2022 GMT+0.

Table of Contents


1 Introduction

Defmemo

Defmemo is a generic defun form, performing memoization over calls to such defined function. It supports arbitrary lambda lists and multiple return values. (optimize speed)-friendly, otherwise it might have been implemented as in Peter Norvig's PAIP. Preserves arguments and documentation. Memoizing hash table is stored under property :memo of defmemo'ed function.

Usage

Three functions are exported: defmemo (like defun), get-memo and clear-memo (defmemo'ed symbol). Clear-memo is not needed on implementations supporting weak hash tables (via trivial-garbage).

(defmemo fib (n)
  (if (<= n 1)
      1
      (+ (fib (- n 1))
         (fib (- n 2)))))

(fib 100)
; => 573147844013817084101

(get-memo 'fib)
; => #<hash-table :TEST equal :COUNT 101 :WEAKNESS :key>

(hash-table-count (clear-memo 'fib))
; => 0

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 defmemo

Memoizing defun

Author

Orivej Desh <orivej@gmx.fr>

License

Unlicense <http://unlicense.org/UNLICENSE>

Version

1.5

Dependencies
  • alexandria (system).
  • trivial-garbage (system).
Source

defmemo.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 defmemo/defmemo.asd

Source

defmemo.asd.

Parent Component

defmemo (system).

ASDF Systems

defmemo.


3.1.2 defmemo/package.lisp

Source

defmemo.asd.

Parent Component

defmemo (system).

Packages

defmemo.


Previous: , Up: Lisp   [Contents][Index]

3.1.3 defmemo/defmemo.lisp

Dependency

package.lisp (file).

Source

defmemo.asd.

Parent Component

defmemo (system).

Public Interface
Internals

flat-arglist (function).


4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 defmemo

Source

package.lisp.

Use List
  • alexandria.
  • common-lisp.
  • trivial-garbage.
Public Interface
Internals

flat-arglist (function).


5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Macros

Macro: defmemo (name args &body body)

Construct defun with body wrapped into memoizing hash table. Put the latter under :memo property of name.

Package

defmemo.

Source

defmemo.lisp.


Previous: , Up: Public Interface   [Contents][Index]

5.1.2 Ordinary functions

Function: clear-memo (symbol)

Reset memoizing hash table.

Package

defmemo.

Source

defmemo.lisp.

Function: get-memo (symbol)

Get memoizing hash table.

Package

defmemo.

Source

defmemo.lisp.

Function: (setf get-memo) (symbol)

Replace memoizing hash of symbol with value.

Package

defmemo.

Source

defmemo.lisp.


5.2 Internals


Previous: , Up: Internals   [Contents][Index]

5.2.1 Ordinary functions

Function: flat-arglist (args)

Convert ordinary lambda list into funcallable list.

Package

defmemo.

Source

defmemo.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables