[plt-scheme] HTDP 12.4.2

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Wed Jun 21 22:10:01 EDT 2006

Hi Wooks Wooks,

A few more comments: try not to skip the design recipe steps, or to 
"backport" work from hacking into filling in the design recipe blanks. I 
don't see a template for insertEverywhere, and the template for infiltrate 
is just, well, silly.  *wink*

> ;(define (infiltrate infiltrator front back)
> ;   (cond
> ;      [(empty? back) ....]
> ;      [(empty? front) ..(infiltrate infiltrator (list (first back)) (rest 
> back).]
> ;      [else (..... (infiltrate infiltrator (append front (list (first 
> back))) (rest back))]
> ;    )
> ;  )

How could the template know that it should use *list* in one place or 
*append* in another?  I'm just begging the question.  The point is that 
this just has a strange design to it --- it's doing way too much work, and 
I'm not convinced it even does the right thing.

In fact, I know it's doing too much work: the function will work fine here 
without the middle case (the one checking front for empty?).

In terms of design recipe terminology, you have a function here that 
should technically be following the first case of:


but seeing that that recipe is in Section 17, and that your problem comes 
from section 12.4, is a very strong hint that a wrong turn has been taken 
here.  *grin*

The point is that if we start skipping the design recipe steps in favor of 
hacking the problem out, we're bound to dig ourselves into a hole.  I'd 
strongly recommend re-doing the design recipe for insertEverywhere. 
Don't skip the steps!  Here's the link to the relevant recipe:


You should be able to do insertEverywhere with that design pattern.

Good luck!

Posted on the users mailing list.