From 6e0077bacabbdc270302e89c9f0f0a12240ae0c3 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Fri, 1 Apr 2016 20:20:12 +0200 Subject: [PATCH] Fix caching bug which caused the limit to be ignored during recursion --- memoize.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/memoize.scm b/memoize.scm index 681ca13..8612404 100644 --- a/memoize.scm +++ b/memoize.scm @@ -51,11 +51,11 @@ (lambda args (let ((results (hash-table-ref/default cache args not-found))) (cond ((eq? results not-found) - ;; Avoid a huge cache by deleting random keys if limit is determined. - (and limit (>= (hash-table-size cache) limit) (delete-random-key! cache)) (let ((results (call-with-values (lambda () (apply proc args)) list))) + ;; Avoid a huge cache by deleting random keys if limit is determined. + (and limit (>= (hash-table-size cache) limit) (delete-random-key! cache)) (hash-table-set! cache args results) (apply values results))) (else -- 2.1.4