From 9aa63e1c009caa1a95fe24d477d4cecdb4ecb9cb Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sat, 28 Jan 2017 03:19:02 -0800 Subject: [PATCH] Implement simple-{list,lset}-memoizer to capture common pattern. --- src/runtime/memoizer.scm | 19 +++++++++++++++++++ src/runtime/runtime.pkg | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/runtime/memoizer.scm b/src/runtime/memoizer.scm index 0df1e6e2b..032edceeb 100644 --- a/src/runtime/memoizer.scm +++ b/src/runtime/memoizer.scm @@ -124,4 +124,23 @@ USA. (lambda () (set! list-memoizer (make-list-memoizer make-list= #f)) (set! lset-memoizer (make-list-memoizer make-lset= #t)) + unspecific)) + +(define (make-simple-list-memoizer list-memoizer) + (lambda (elt= get-key get-datum) + (let ((memoizer + (list-memoizer elt= + (lambda (args) + (apply get-key args)) + (lambda (args) + (apply get-datum args))))) + (lambda args + (memoizer args))))) + +(define simple-list-memoizer) +(define simple-lset-memoizer) +(add-boot-init! + (lambda () + (set! simple-list-memoizer (make-simple-list-memoizer list-memoizer)) + (set! simple-lset-memoizer (make-simple-list-memoizer lset-memoizer)) unspecific)) \ No newline at end of file diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index 9c6caa3e6..372f7a1c1 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -2547,6 +2547,8 @@ USA. memoizer-table memoizer-procedure memoizer? + simple-list-memoizer + simple-lset-memoizer weak-eqv-memoizer)) (define-package (runtime history) -- 2.25.1