(define (memoize message f)
(define (dispatch message)
(cond
((eq? message 'm) k)
((eq? message 'um) 20)))
(define (k)
(let ((table (make-table)))
(lambda (x)
(let ((previously-computed-result (lookup x table)))
(or previously-computed-result
(let ((result (f x)))
(insert! x result table)
result)
)))))
f)
(set! fib(memoize 'm fib))
My idea is that I am sending m, as the message, then the ((eq? message 'm) k) will check true so define k will run and change the fib because of set!, but the code does not work as I expect it to work, could someone help me out please