Cut-over to Cyc-memoize

This commit is contained in:
Justin Ethier 2019-02-14 12:47:36 -05:00
parent 4632efc71d
commit 12b6131992
2 changed files with 22 additions and 22 deletions

View file

@ -3,27 +3,27 @@
(srfi 69)
(scheme write))
(define (memoize function)
(let ((table (make-hash-table))) ;(make-equal?-map)))
(lambda args
(apply values
;(map-get table
(hash-table-ref table
args
;; If the entry isn't there, call the function.
(lambda ()
(call-with-values
(lambda () (apply function args))
(lambda results
;(map-put! table args results)
(hash-table-set! table args results)
results))))))))
(define (fnc x y) (+ x y))
(define mfnc (memoize fnc))
(write (mfnc 1 1)) (newline)
(write (mfnc 1 1)) (newline)
; (define (memoize function)
; (let ((table (make-hash-table))) ;(make-equal?-map)))
; (lambda args
; (apply values
; ;(map-get table
; (hash-table-ref table
; args
; ;; If the entry isn't there, call the function.
; (lambda ()
; (call-with-values
; (lambda () (apply function args))
; (lambda results
; ;(map-put! table args results)
; (hash-table-set! table args results)
; results))))))))
;
;(define (fnc x y) (+ x y))
;(define mfnc (memoize fnc))
;
;(write (mfnc 1 1)) (newline)
;(write (mfnc 1 1)) (newline)
; Original versions:
(define (ack m n)

View file

@ -193,7 +193,7 @@
(set-global! ,var ,rsym)
,acc)))
)
`(memoize
`(Cyc-memoize
,(ast:make-lambda (list rsym) body)
,new-var)))
exp