<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<br><div><html>On Mar 27, 2008, at 2:12 PM, Cooke Kelsey wrote:</html><br class="Apple-interchange-newline"><blockquote type="cite"><div>Here's the answers to your questions:</div>  <div> </div>  <div>Q: What do you mean with (rest ..) ?  This doesn't look like my table. </div>  <div> </div>  <div> A: Your table says, "(insert-everywhere/in-all-words s (rest low)," which means I would rewrite the whole function in the column? </div></blockquote><div><br></div><div>I want to know what the result of (insert-everywhere/in-all-words s (rest low)) would be when low = ... </div><div>(Looking more closely, your second row says you did the right thing.) </div><div><br></div><div><br></div><blockquote type="cite">  <div> <span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">[This isn't quite right! 'AT is NOT the representation of the English word "at".]</span></div>  <div> </div>  <div>  A: I was trying to use shorthand from Intermezzo 2:</div><pre class="schemeresponse"><span class="keyword">'</span>(<span class="variable">a</span> <span class="variable">b</span> <span class="variable">c</span>)  <span class="comment">This short-hand is an abbreviation for</span>  (<span class="builtin">list</span> <span class="keyword">'</span><span class="variable">a</span> <span class="keyword">'</span><span class="variable">b</span> <span class="keyword">'</span><span class="variable">c</span>)  </pre></blockquote><div><br></div><div>Then what is '(AT)? Hint: you used ' improperly, and that is common for beginners. I recommend you stick to (list 'a 'b 'c) and (list (list 'a) (list 't)) and so on. </div><div><br></div><div><br></div><blockquote type="cite">  <div> <span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">Q: Why not take one step from row 1, which uses a list with one word. What would be the next case? </span></div>  <div> </div>  <div>A: Um, two words.  I have no idea why I did that.</div></blockquote><div><br></div><div>Make up a simpler example. Simple examples are good. </div><div><br></div><br><blockquote type="cite">  <div><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">Q: The second leap went wrong. Why? Is it possible that you JUMPED?  Why don't you turn the above examples into examples for this function. And *please* do provide a contract, a purpose statement. </span></div>  <div> </div>  <div>A: OK, this is where my big problem is.  I'm not sure what you mean by JUMPED.  Can you be more specific?  I realize this is some kind of clue but I am too slow to get it. </div></blockquote><div><br></div><div>JUMPED means you wrote the helper function w/o contract, purpose statement, template, examples. </div><div><br></div><div><br></div><br><blockquote type="cite"><div> </div>  <div> <span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">Here's a full design recipe:</span></div>  <div> </div>  <div>; Purpose: to insert a symbol between every letter of a single word<br>; Contract: symbol word --> list of words<br>; Example: (define (insert-in-single-word X AT).  Result should be (XAT AXT ATX)</div></blockquote><div><br></div><div>(0) The example is _conceptually_ correct (meaning at the information level). </div><div><br></div><div>(1) At this point it becomes critical to spell out the (list ...) stuff, i.e., to turn the example into full-fledged Scheme data. Small step. </div><div>(2) I propose you make a second example again. </div><div><br></div><br><blockquote type="cite"><div>; Template: <br>;   (define (insert-in-single-word s word)<br>;     (cond<br>;       [(empty? (rest word)) empty]<br>;       [else (append (list (first word) s (rest word)) (insert-in-single-word s (rest word)))]))</div></blockquote><div><br></div><div>This is NOT a template. </div><div><br></div><div>And before you complete the template build a table just like the one above for the recursive case. </div><div><br></div><div>-- Matthias</div><div><br></div><div><br></div><div><br></div><br><blockquote type="cite"><div><br></div>  <div>Thanks very much.<br><br><b><i>Matthias Felleisen &lt;<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>></i></b> wrote:</div>  <blockquote class="replbq" style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"><br>  <div>On Mar 27, 2008, at 1:20 PM, Cooke Kelsey wrote:<br class="Apple-interchange-newline">  <blockquote type="cite">  <div>Dear Dr. Felleisen, </div>  <div>thanks so much for responding!  Your suggestions really helped me to think about the problem.</div>  <div> </div>  <div>Here's a table of examples, as you suggested:</div>  <div> </div>  <div>;;Examples <br>; s | low              |(first..)|(rest..)    | result</div></blockquote>  <div><br></div>  <div>Q: What do you mean with (rest ..) ?  This doesn't look like my table. </div>  <div><br></div><br>  <blockquote type="cite">  <div>;--------------------------------------------------------------------------------------------------------<br>; X | '(AT)            |'(AT)    |empty       | '((XAT) (AXT) (ATX))</div></blockquote>  <div><br></div>  <div><br></div>  <div>[This isn't quite right! 'AT is NOT the representation of the English word "at".]</div>  <div><br></div><br>  <blockquote type="cite">  <div>; X | '((AB) (CD) (EF))|'(AB)    |'((CD) (EF))| '((XAB) (AXB) (ABX) (XCD) (CXD) (CDX) (XEF) (EXF) (EFX))</div></blockquote>  <div><br></div>This second row looks hyper-complicated. </div>  <div><br></div>  <div>Q: Why not take one step from row 1, which uses a list with one word. What would be the next case? </div>  <div><br></div>  <div>  <div><br></div>  <div><br></div><br>  <blockquote type="cite">  <div><span class="Apple-style-span" style="-webkit-text-stroke-width: -1">Here's an attempt to "go from the first columns to the last": </span></div>  <div><br>; Definitions:<br>(define (insert-everywhere/in-all-words s low)<br>  (cond<br>    [(empty? (rest low)) empty]<br>    [else (append (insert-in-single-word s (first low)) (insert-everywhere/in-all-words s (rest low)))]))</div></blockquote>  <div><br></div>  <div>Good the first leap went fine. </div>  <div><br></div><br>  <blockquote type="cite">  <div> <span class="Apple-style-span" style="-webkit-text-stroke-width: -1">(define (insert-in-single-word s word)</span></div>  <div>  (cond<br>    [(empty? (rest word)) empty]<br>    [else (append (list (first word) s (rest word)) (insert-in-single-word s (rest word)))]))</div></blockquote>  <div><br></div>  <div>The second leap went wrong. Why? </div>  <div><br></div>  <div>Is it possible that you JUMPED?  Why don't you turn the above examples into examples for this function. And *please* do provide a contract, a purpose statement. </div>  <div><br></div>  <div>-- Matthias</div>  <div><br></div>  <div><br></div><br>  <blockquote type="cite">  <div><br></div>  <div>Unfortunately, the list of words gets shorter and shorter (sATX, sTX, sX).  I tried to think of a way to add a recursive "prefix" that gets longer, but each time the function cycles the first letters seem to disappear into the void...</div>  <div><br><b><i>Matthias Felleisen &lt;<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>></i></b> wrote:</div>  <blockquote class="replbq" style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"><br>  <div>On Mar 25, 2008, at 1:48 PM, Cooke Kelsey wrote:   <blockquote type="cite">  <div><span class="Apple-style-span" style="-webkit-text-stroke-width: -1">I am trying to learn HtDP by myself, and like Dave Yrueta I am stumped by 12.4.2. </span></div></blockquote>  <div><br></div>[Oops I forgot to reply to his last message.]<br><br><br>  <blockquote type="cite">  <div><span class="Apple-style-span" style="-webkit-text-stroke-width: -1">; Purpose: to insert a symbol between every letter of every word, e.g. X, AT-->XAT, AXT, ATX.</span></div></blockquote>  <div><br></div>  <div>Please reformulate the example in terms of symbols and lists. </div>  <div><br></div><br>  <blockquote type="cite">  <div> <span class="Apple-style-span" style="-webkit-text-stroke-width: -1">;Function Template: </span></div>  <div>(define (insert-everywhere/in-all-words s low)<br>  (cond<br>    [(empty? (rest low))...]<br>    [else ...(first low)...insert-everywhere/in-all-words s (rest low)]))<br></div>  <div>Note: </div>  <div>It is suggested to use "append", which is easy one or two times---(append x word) or (append (append (first word) x) (rest word))----but I can't see how to use this recursively for an arbitrary number of letters and words. </div></blockquote>  <div><br></div>  <div>So far so good. Let's try what HtDP/2e will introduce: </div>  <div><br></div>  <div>Please make a table of the following shape: </div>  <div><br></div>  <div> s   |   low  |   (first low)  |  (insert-everywhere/in-all-words s (rest low) | expected result for (insert-... s low)</div>  <div>--------------------------------------------------------------------------------------------------------</div>  <div> X   |   AT   |     ?             |  use the purpose statement to determine this |   (list `XAT' `AXT' `ATX')</div>  <div><br></div>  <div><br></div>  <div>As I said, you need to reformulate this in terms of symbols and lists. If it doesn't jump out at you how to go from the four columns to the last one, then make a couple of more examples. I am pretty sure it will. Here is the rule of thumb: </div>  <div><br></div>  <div> --> you know of a built-in function/primitive that does the work </div>  <div> --> you don't. in this case, you make a wish: a purpose statement and a contract for a helper function that does it for you. </div>  <div><br></div>  <div>You may also have to combine a primitives with functions. </div>  <div><br></div>  <div>Please report back -- Matthias</div>  <div><br></div>  <div><br></div>  <div><br></div>  <div><br></div>  <div><br></div>  <div><br></div><br>  <blockquote type="cite">  <div></div>  <div> </div>  <div>The fact that the "hint" refers to the keyword list, which the book hasn't covered yet, makes me wonder if it's even possible to answer this problem, given what we know so far...</div>  <div> </div>  <div>Thanks very much, </div>  <div> </div>  <div>Cooke</div>  <div><br class="khtml-block-placeholder"></div>  <hr size="1">  Looking for last minute shopping deals? <a href="http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping">Find them fast with Yahoo! Search.</a>   <div style="MARGIN: 0px">_________________________________________________</div>  <div style="MARGIN: 0px"><span class="Apple-converted-space">  </span>For list-related administrative tasks:</div>  <div style="MARGIN: 0px"><span class="Apple-converted-space">  </span><a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a></div></blockquote></div><br></blockquote><br>  <div><br class="khtml-block-placeholder"></div>  <hr size="1">  Looking for last minute shopping deals? <a href="http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping">Find them fast with Yahoo! Search.</a></blockquote></div><br></blockquote><br><div>        <br class="khtml-block-placeholder"></div><hr size="1">Never miss a thing.  <a href="http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs"> Make Yahoo your homepage.</a></blockquote></div><br></body></html>