|
|
@ -1,8 +1,9 @@
|
|
|
|
#lang racket/base
|
|
|
|
#lang racket/base
|
|
|
|
(require (for-syntax racket/base))
|
|
|
|
(require (for-syntax racket/base) racket/contract)
|
|
|
|
(provide (all-defined-out))
|
|
|
|
(provide (all-defined-out))
|
|
|
|
|
|
|
|
|
|
|
|
(define (make-caching-proc base-proc)
|
|
|
|
(define/contract (make-caching-proc base-proc)
|
|
|
|
|
|
|
|
(procedure? . -> . procedure?)
|
|
|
|
(let ([cache (make-hash)])
|
|
|
|
(let ([cache (make-hash)])
|
|
|
|
(λ args
|
|
|
|
(λ args
|
|
|
|
(hash-ref! cache args (λ () (apply base-proc args))))))
|
|
|
|
(hash-ref! cache args (λ () (apply base-proc args))))))
|
|
|
|