Commit f9b3a258 authored by Francois-Rene Rideau's avatar Francois-Rene Rideau
Browse files

Adding a build.xcvb, and minor tweaks.

parent 346d3c70
......@@ -8,7 +8,9 @@ to focus on the computation logic and handles the caching part for you.
It also allows you to memoize a function after the fact when you need it.
Obviously, you should only use memoization for functions where it is meaningful:
pure functions that are expensive to compute,
non-deterministic functions for which it matters that choices be consistent, etc.
non-deterministic functions for which it matters that choices be consistent,
hash-consing constructors that need return the same result when called with
the same arguments, user-visible constructors for singleton classes, etc.
This file first documents the interface of this library, then
compares fare-memoization to previous memoization libraries,
......
#+xcvb
(module
(:fullname "fare-memoization"
:depends-on ("memoization")
:supersedes-asdf ("fare-memoization")))
......@@ -10,8 +10,6 @@
:in root-suite
:documentation "Testing memoization"))
;;; No test just yet.
(defparameter *counter* 0)
(declaim (notinline foo))
(defun foo (x) (list x (incf *counter*)))
......@@ -58,4 +56,5 @@
(is (equal (quux :a) '(:a 1)))
(is (equal (quux :b) '(:b 12)))
(is (equal (quuux :a) '(:a 1)))
(is (equal (quuux :b) '(:b 12))))
(is (equal (quuux :b) '(:b 12)))
(is (eq (memoized-funcall 'cons 1 2) (memoized-funcall 'cons 1 2))))
......@@ -100,11 +100,11 @@ Keyword arguments TABLE and NORMALIZATION are as per MEMOIZE."
;;; arguments that you don't want memoized in dynamic variable bindings.
(defvar *memoized* (make-hash-table :test 'equal))
(define-memo-function (memoized-funcall :table *memoized*) (fun &rest arguments)
(define-memo-function (memoized-funcall :table *memoized*) (function &rest arguments)
"This is a generic memoized function"
(apply fun arguments))
(apply function arguments))
(defun memoized-apply (fun &rest args)
(apply #'apply #'memoized-funcall fun args))
(defun memoized-apply (function &rest arguments)
(apply #'apply #'memoized-funcall function arguments))
);eval-when
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment