aboutsummaryrefslogtreecommitdiff
path: root/gn3-guile
diff options
context:
space:
mode:
Diffstat (limited to 'gn3-guile')
-rwxr-xr-xgn3-guile/web/webserver.scm13
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")