Code from the text.
3.50
3.51
It is confusing for me to understand this memo-proc
function.
All the delayed
functions are cached after the first running.
3.52
sum
acts as a global value, which is a bad idea in the stream.
When the delay
is memorized
, seq
is the same no matter how many times it is called.
If the non-memorized
version is used, then seq
would have different result
because of the sharing sum
.
3.53
(1 2 4 8 16 32 …)
3.54
3.55
3.56
3.57
memorized
version is $O(n)$ while naive version is $O(2^n)$
3.58
It is long divide.
3.59
3.60
$(h1 + tail1) * (h2 + tail2) = h1 * h2 + h1tail2 + tail1(h2+tail2)$
3.61
3.62
The den
should be normalized to have the $constant=1$