defining a procedure: (define (identifier arg1 arg2 …) …)

defining a variable: (define identifier )

where expression could be a primitive like ‘value or the application of a function (+ 2 3) where the value of memo-fib stays a consistent 5 and is never recalculated.

rather a variable whose value is the result of applying memoize to the lambda expression that looks exactly like fib except the recursive steps are memo-fib and not fib.

If we wrote this in javascript it would look like this:

memo-fib = memoize((n) => {

if (n = 0) return 0;

if (n = 1) return 1;

return memo-fib (n-1) + memo-fib (n-2);

};

memo-fib = memoize((f) => {

let table = make-table();

x => {

let previously-computed-result = lookup(x, table);

if (previously-computed-result)

return previously-computed-result;

let result = f(x);

insert!(x, result, table);

return result;

};

})((n) => {

if (n = 0) return 0;

if (n = 1) return 1;

return memo-fib (n-1) + memo-fib (n-2);

});

I think seeing this in an imperative form makes it easier to see that memo-fib becomes the procedure returned by memoize and stays that same functions for all the recursive calls that updates it’s local table and that the recursive step is calling this same memo-fib defined in the global environment.

]]>