[Small-cl-src] Semi-generic defmemo (list test)

Ingvar ingvar at cathouse.bofh.se
Thu May 13 21:49:27 UTC 2004


;; Should test for "is in hash table", rather than NIL-ness
(defmacro defmemo (name lambda-list &rest body)
  (let ((memo (make-hash-table :test #'equal)) (tmp (gensym)))
    `(flet ((,tmp ,lambda-list , at body))
       (defun ,name (&rest args)
         (or (gethash args, memo)
             (setf (gethash args ,memo) (apply #',tmp args)))))))






More information about the Small-cl-src mailing list