View difference between Paste ID: GPZhAwgd and xCPhBEeq
SHOW: | | - or go back to the newest paste.
1
(define (caching f)
2
  (define ht (make-hash))
3
  (lambda (x) 
4-
    (define y (hash-ref ht x #f))
4+
    (let ((y (hash-ref ht x #f)))
5-
    (unless y
5+
      (hash-set! ht x (or y (f x))))
6-
      (set! y (f x))
6+