diff options
author | Pjotr Prins | 2023-08-04 14:11:52 +0200 |
---|---|---|
committer | Pjotr Prins | 2023-08-04 14:11:52 +0200 |
commit | 58949ddd80e2fd47e039ed96630852e49d7d93e9 (patch) | |
tree | 44a78a6092249f4f184fef1a1c6412f263857542 | |
parent | 1c0b72030ce3fdc67bba3fd2d18864dd1cfd9bb0 (diff) | |
download | genenetwork3-58949ddd80e2fd47e039ed96630852e49d7d93e9.tar.gz |
Start on memoize
-rwxr-xr-x | gn3-guile/web/webserver.scm | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gn3-guile/web/webserver.scm b/gn3-guile/web/webserver.scm index cddd9a5..7428640 100755 --- a/gn3-guile/web/webserver.scm +++ b/gn3-guile/web/webserver.scm @@ -17,6 +17,7 @@ ;; (ice-9 breakpoints) ;; (ice-9 source) (srfi srfi-1) + (srfi srfi-13) ; hash table for memoize (srfi srfi-26) (web http) (web client) @@ -25,6 +26,18 @@ (web uri) (fibers web server)) +(define (memoize function) + (let ((table (make-hash-table))) + (lambda args + (apply values (hash-ref table args + ;; If the entry isn't there, call the function. + (lambda () + (call-with-values + (lambda () (apply function args)) + (lambda results + (hash-set! table args results) + results)))))))) + (define get-version "2.0") |