This preview shows page 1. Sign up to view the full content.
Unformatted text preview: 4.29 Memoizing or not You'd expect a program that uses the same argument repeatedly to be most strongly affected. For example, I wrote (define (n-copies n stuff) (if (= n 0) '() (cons stuff (n-copies (- n 1) stuff)))) Then if you use n-copies with something requiring a fair amount of computation, such as (n-copies 6 (factorial 7)) you can see a dramatic difference. About their square/id example, remember to (set! count 0) before each experiment. Then the memoizing version leaves count at 1, whereas the non-memoizing version sets count to 2. [The continuation part of the lab was just try-this.]...
View Full Document
- Spring '08