Question: In this task, we write a function build mem that takes an input function and returns a function that is the memoized version of the
In this task, we write a function build mem that takes an input function and returns a function that is the memoized version of the input function. That is (build mem fib) should return a function behaving the same as fib mem. For simplicity, you can assume the input function takes exactly one parameter. As before, the returned function should display the message memoization hit when given an input that is already in the association list.
Hint: the function returned by build mem should have its own association list, which cannot be defined as a global variable. Introduce a local variable instead. That is, the function build mem should be defined in the following way:
(define (build_mem f)
(let ((al ()))
(lambda (n) ... )))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
