Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Memoize Thunk
(define (force-it obj)
(if (thunk? obj)
(define-in-environment (name thunk-exp) list('evaluated-thunk ((actual-value (thunk-exp obj) (thunk-env obj))))
obj))
...
(define (evaluated-thunk? obj)
(eq? (car obj) 'evaluated-thunk))
(define (thunk-value evaluated-thunk) (cadr evaluated-thunk))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.