[plt-scheme] HTDP 12.4.2

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Thu Jun 22 23:47:44 EDT 2006


On Thu, 22 Jun 2006, wooks wooks wrote:

>
> So, if we are holding onto:
>
>   (list (list 'd 'r 'e)
>         (list 'r 'd 'e)
>         (list 'r 'e 'd))
>
> and we want to mess with it enough so we get:
>
>    (list (list 'd 'e 'r)
>          (list 'e 'd 'r)
>          (list 'e 'r 'd)
>          (list 'd 'r 'e)
>          (list 'r 'd 'e)
>          (list 'r 'e 'd))
>
> do you see what the difference between what we're holding onto and what we 
> want is?  Can you give a concept or name to it?
>
>
> The difference is (first alow) - Right.


Hi Wooks Wooks,

I'm not quite sure if we've done that mind meld thing yet, where we both 
are sharing the same thoughts.  *grin* Can you be more specific?


How can (first alow), which is going to be the list

          (list 'e 'r)

then account for the difference between:

    (list (list 'd 'r 'e)
          (list 'r 'd 'e)
          (list 'r 'e 'd))

which is what we have on hand, and the result that we really want to get 
back:

    (list (list 'd 'e 'r)
          (list 'e 'd 'r)
          (list 'e 'r 'd)
          (list 'd 'r 'e)
          (list 'r 'd 'e)
          (list 'r 'e 'd))

I'm not saying that it isn't, but that if we're going to say that it is, 
we have to fill in a few more ...'s till we can tell the non-thinking 
computer how to do what we think we mean.



That is, recalling that portion of the template we were looking at 
earlier,

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     [else ... sym ... (first alow) ...
           ... (insertEverywhere sym (rest alow)) ...]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

and knowing what the expected return value is now, can you think of how to 
complete the definition now?



If not, one way to make things easier is to fill the template will 
concrete values, based on the test case you worked out, and see if that 
will help:

     (... sym ... (first alow) ...
          ... (insertEverywhere sym (rest alow)) ...)

==>

     (... 'd  ... (list 'e 'r) ...
          ...  (list (list 'd 'r 'e)
                     (list 'r 'd 'e)
                     (list 'r 'e 'd)) ...)

Does this help?


Note that the steps we've done haven't been particularly brilliant.  One 
could rephrase the steps we're doing here as:

     1.  Shaping the general program pattern.
     2.  Cooking up simple test cases.
     3.  Mixing in those test case situations into the pattern.

We aren't aren't doing anything that couldn't be really codified in some 
strategy, some... well, let's call this thing a "design recipe" for lack 
of a better term.  *wink*


Posted on the users mailing list.