<div>Hallelujah......I've pretty much got it!&nbsp; </div>  <div>&nbsp;</div>  <div>I don't exactly get the correct answer (see below), but it pretty much works:</div>  <div>&nbsp;</div>  <div>;MAIN FUNCTION: arrangements: word --&gt; list of words</div>  <div>(define (arrangements a-word)<BR>&nbsp; (cond [(empty? a-word) (cons empty empty)]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [else (insert-everywhere/in-all-words (first a-word) (arrangements (rest<BR>&nbsp;a-word)))]))</div>  <div>&nbsp;</div>  <div>;HELPER #1: insert-everywhere/in-all-words : letter, list of words --&gt; list of words</div>  <div>(define (insert-everywhere/in-all-words s low)<BR>&nbsp; (cond<BR>&nbsp;&nbsp;&nbsp; [(empty? (rest low)) (insert-everywhere/one-word s (first low))]<BR>&nbsp;&nbsp;&nbsp; [else (append (insert-everywhere/one-word s (first low)) (insert-everywhere/in-all-words s (rest low)))]))</div>  <div>&nbsp;</div>  <div>;HELPER #2: insert-everywhere/one-word : letter, word --&gt;
 list of words</div>  <div>;NOTE: this function just adds the last word to Helper #3</div>  <div>(define (insert-everywhere/one-word letter a-word)<BR>&nbsp; (append (list (append a-word (list letter))) (insert-everywhere-except-last-letter letter a-word)))</div>  <div>&nbsp;</div>  <div>;HELPER #3: insert-everywhere-except-last-letter : letter, word --&gt; list of words</div>  <div>(define (insert-everywhere-except-last-letter letter a-word)<BR>&nbsp; (cond<BR>&nbsp;&nbsp;&nbsp; [(empty? a-word) (cons empty empty)]<BR>&nbsp;&nbsp;&nbsp; [(empty? (rest a-word)) (cons (list letter (first a-word)) empty)]<BR>&nbsp;&nbsp;&nbsp; [else (cons (cons letter a-word) (add-first-letter (first a-word) (insert-everywhere-except-last-letter letter (rest a-word))))]))</div>  <div>; NOTE: THERE IT IS!&nbsp; the expression I couldn't figure out: "(cons (cons letter a-word) (add-first-letter (first a-word) (insert... letter (rest a-word))))"</div>  <div>&nbsp;</div>  <div>;HELPER #4 :
 add-first-letter : letter, list of words --&gt; list of words</div>  <div>(define (add-first-letter letter low)<BR>&nbsp; (cond <BR>&nbsp;&nbsp;&nbsp; [(empty? (rest low)) (cons (append (list letter) (first low)) empty)]<BR>&nbsp;&nbsp;&nbsp; [else (cons (append (list letter) (first low)) (add-first-letter letter (rest low)))]))</div>  <div><BR>;test</div>  <div>(arrangements (list 'd 'a 'r 'e))</div>  <div>;expected result:</div>  <div>;(list<BR>; (list 'e 'r 'a 'd)<BR>; (list 'd 'e 'r 'a)<BR>; (list 'e 'd 'r 'a)<BR>; (list 'e 'r 'd 'a)<BR>; (list 'a 'e 'r 'd)<BR>; (list 'd 'a 'e 'r)<BR>; (list 'a 'd 'e 'r)<BR>; (list 'a 'e 'd 'r)<BR>; (list 'e 'a 'r 'd)<BR>; (list 'd 'e 'a 'r)<BR>; (list 'e 'd 'a 'r)<BR>; (list 'e 'a 'd 'r)<BR>; (list 'r 'e 'a 'd)<BR>; (list 'd 'r 'e 'a)<BR>; (list 'r 'd 'e 'a)<BR>; (list 'r 'e 'd 'a)<BR>; (list 'a 'r 'e 'd)<BR>; (list 'd 'a 'r 'e)<BR>; (list 'a 'd 'r 'e)<BR>; (list 'a 'r 'd 'e)<BR>; (list 'r 'a 'e 'd)<BR>; (list 'd 'r 'a 'e)<BR>; (list
 'r 'd 'a 'e)<BR>; (list 'r 'a 'd 'e))</div>  <div>&nbsp;</div>  <div>; actual result:</div>  <div>;(list<BR>; (list 'e 'r 'a 'd)<BR>; (list 'd 'e 'r 'a)<BR>; (list 'e 'd 'r 'a)<BR>; (list 'e 'r 'd 'a)<BR>; (list 'a 'e 'r 'd)<BR>; (list 'd 'a 'e 'r)<BR>; (list 'a 'd 'e 'r)<BR>; (list 'a 'e 'd 'r)<BR>; (list 'e 'a 'r 'd)<BR>; (list 'd 'e 'a 'r)<BR>; (list 'e 'd 'a 'r)<BR>; (list 'e 'a 'd 'r)<BR>; (list 'r 'e 'a 'd)<BR>; (list 'd 'r 'e 'a)<BR>; (list 'r 'd 'e 'a)<BR>; (list 'r 'e 'd 'a)<BR>; (list 'a 'r 'e 'd)<BR>; (list 'd 'a 'r 'e)<BR>; (list 'a 'd 'r 'e)<BR>; (list 'a 'r 'd 'e)<BR>; (list 'r 'a 'e 'd)<BR>; (list 'd 'r 'a 'e)<BR>; (list 'r 'd 'a 'e)<BR>; (list 'r 'a 'd 'e)<BR>; (list 'r 'a 'd)<BR>; (list 'd 'r 'a)<BR>; (list 'r 'd 'a)<BR>; (list 'a 'r 'd)<BR>; (list 'd 'a 'r)<BR>; (list 'a 'd 'r)<BR>; (list 'a 'd)<BR>; (list 'd 'a)<BR>; (list 'd)<BR>; empty)<BR><BR><B><I>Matthias Felleisen &lt;matthias@ccs.neu.edu&gt;</I></B> wrote:</div>  <BLOCKQUOTE class=replbq
 style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"><BR>  <DIV>On Mar 28, 2008, at 9:03 PM, Cooke Kelsey wrote:<BR class=Apple-interchange-newline>  <BLOCKQUOTE type="cite">  <DIV>Here's an answer to your question:</DIV>  <DIV>&nbsp;</DIV>  <DIV>Q: "Can you design a function that adds a letter (no matter what it is) to the front of all these words you have gotten back?...DONE?&nbsp;After that: what is missing?"</DIV></BLOCKQUOTE>  <DIV><BR></DIV>  <DIV>NO! NO!&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>Look at the table for a call to insert-everywhere/one-word with 'X and (list 'A 'T). &lt;&lt;--- original call&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>&nbsp;If you now recursively call&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>&nbsp;* (insert-everywhere/one-word s (rest word)) and get&nbsp;</DIV>  <DIV>&nbsp;&nbsp; (list (list 'X 'T)&nbsp;</DIV>  <DIV>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(list 'T 'X))&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>and then you call&nbsp;</DIV> 
 <DIV><BR></DIV>  <DIV>&nbsp;* &nbsp;(add-letter-to-all (first word) ... the above ..) you get&nbsp;</DIV>  <DIV>&nbsp;&nbsp; &nbsp; (list (list 'A 'X 'T)&nbsp;</DIV>  <DIV>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(list 'A 'T 'X))</DIV>  <DIV><BR></DIV>  <DIV>What do you want for the result of the original call?&nbsp;</DIV>  <DIV>How can you add this to what you have so far?&nbsp;</DIV>  <DIV>(10 keystrokes)</DIV>  <DIV><BR></DIV>  <DIV>That's the question I raise. -- Matthias</DIV>  <DIV><BR></DIV>  <DIV><BR></DIV>  <DIV><BR></DIV>  <DIV><BR></DIV>  <DIV><BR></DIV>  <DIV><BR></DIV>  <DIV><BR></DIV>  <DIV><BR></DIV>  <DIV><BR></DIV><BR>  <BLOCKQUOTE type="cite">  <DIV>&nbsp;</DIV>  <DIV>A: What's missing is the second letter, the third, etc.&nbsp;&nbsp; </DIV>  <DIV>&nbsp;</DIV>  <DIV>That is, I can add "W" to a list:</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp;(list 'w 'x 'a 't 'e 'r)<BR>&nbsp;(list 'w 'x 't 'e 'r)<BR>&nbsp;(list 'w 'x 'e 'r)<BR>&nbsp;(list 'w 'x 'r))</DIV>
  <DIV>&nbsp;</DIV>  <DIV>But I also need "A" "T" E" "R" to be added, incrementally:</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp;(list 'w 'x 'a 't 'e 'r)<BR>&nbsp;(list 'w 'a 'x 't 'e 'r)<BR>&nbsp;(list 'w 'a 't 'x 'e 'r)<BR>&nbsp;(list 'w 'a 't 'e 'x 'r)</DIV>  <DIV>&nbsp;</DIV>  <DIV>Mark suggested that I look carefully at the table and see how I can "rearrange" the items in the columns to produce the result.&nbsp; Everyone seems to suggest that the answer is found in that table, so I have been copying it and drawing arrows between the letters.&nbsp; </DIV>  <DIV>&nbsp;</DIV>  <DIV>At this point the solution seems to be to create a second shrinking list of (rest words), flip it around backwards and then merge it into the original list.&nbsp; I've written some functions to attempt this, but nothing near the expected result.&nbsp; </DIV>  <DIV>&nbsp;</DIV>  <DIV>Marco has suggested that&nbsp;my entire approach is wrong, that I should build words correctly from the beginning
 instead of adding missing letters.&nbsp; </DIV>  <DIV>&nbsp;</DIV>  <DIV>I'm going to begin again from scratch and pay closer attention to the template and contracts.</DIV>  <DIV>&nbsp;</DIV>  <DIV><BR><B><I>Matthias Felleisen &lt;<A href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</A>&gt;</I></B> wrote:</DIV>  <BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">  <DIV><BR></DIV>  <DIV>Why did you throw away your progress (add-first-letter)?&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>Why did you not answer my second question?&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>(I'll give you that much: with the two you are about 10 keystrokes from the answer.)&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>I am getting the feeling your jumping again.&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>;; ---&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>Let's step back a bit. The purpose of this extended exercise is to practice the two ideas that the book has introduced at that
 point:&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>1. that the design recipe works on a per function basis -- BUT YOU NEED TO STICK TO IT;&nbsp;</DIV>  <DIV>2. that the 'wish list' works -- BUT YOU NEED TO STICK TO IT. &nbsp;(If you are systematic about this, you just never forget where in the problem you are.)&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>;; ---&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>Another step back:&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>1. In case you're wondering: &nbsp;most people would consider this exercise way beyond a first-semester exercise. (It was on my MS exam in 1981.)&nbsp;</DIV>  <DIV><BR></DIV>  <DIV>2. HtDP/2e will use a simpler exercise than that and push back Arrangements until students have more practice. A lot of people have problems with it though in 1-1 meetings, it's much easier to tease out the answers to these questions because the speed is higher and less frustrating.&nbsp;</DIV>  <DIV><BR></DIV>  <DIV><BR></DIV>  <DIV><BR></DIV>  <DIV>-- Matthias</DIV> 
 <DIV><BR></DIV>  <DIV><BR></DIV>  <DIV><BR></DIV>  <DIV><BR></DIV><BR>  <DIV>On Mar 28, 2008, at 5:35 PM, Cooke Kelsey wrote:<BR class=Apple-interchange-newline>  <BLOCKQUOTE type="cite">  <DIV>Dear Matthias / Marco,</DIV>  <DIV>&nbsp;</DIV>  <DIV>I read Marco's suggestions.&nbsp; It was very helpful to read through the whole problem again in clear English and remember how I got to the function "insert-in-single-word."&nbsp; I think I am near to the answer.</DIV>  <DIV>&nbsp;</DIV>  <DIV>You both ask me a similar question:<BR></DIV>  <DIV>(1) Matthias:&nbsp; Can you design a function that adds a letter (no matter what it is) to the front of all these words you have gotten back?...DONE?&nbsp;After that: what is missing?&nbsp;</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp;&nbsp; given: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;the recursion &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; in the final result I
 want&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</DIV>  <DIV>&nbsp;&nbsp;'X &nbsp; "ATE" &nbsp; &nbsp; "X" "TE" --&gt; "XTE" "TXE" "TEX" &nbsp; &nbsp; "AXTE" "ATXE" "ATXE" "ATEX"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR></DIV>  <DIV>(2) Marco: "Here is where I believe you are really stuck. It is easy to see one member of the result: (letter a-word). This puts letter before the first letter of a-word. Is that the only place it can go? No, it can go before any of the letters in a word and at the end of a-word. How do you insert a letter everywhere in (rest a-word)? Once you have this list (call it R) all you need is to do something with (first a-word).&nbsp; Where does it have to go in each of R?"<BR></DIV>  <DIV>&nbsp;</DIV>  <DIV>OK, here is a function which I think answers these questions:</DIV>  <DIV>&nbsp;</DIV>  <DIV>(define (add-letter-to-recursive-list letter
 a-word)<BR>&nbsp; (cond<BR>&nbsp;&nbsp;&nbsp; [(empty? (rest a-word)) (cons (list letter (first a-word)) empty)]<BR>&nbsp;&nbsp;&nbsp; [else (cons (cons letter a-word) (add-letter-to-recursive-list letter (rest a-word)))]))</DIV>  <DIV>&nbsp;</DIV>  <DIV>;example:</DIV>  <DIV>(add-letter-to-recursive-list 'x (list 'w 'a 't 'e 'r))</DIV>  <DIV>;answer</DIV>  <DIV>(list<BR>&nbsp;(list 'x 'w 'a 't 'e 'r)<BR>&nbsp;(list 'x 'a 't 'e 'r)<BR>&nbsp;(list 'x 't 'e 'r)<BR>&nbsp;(list 'x 'e 'r)<BR>&nbsp;(list 'x 'r))</DIV>  <DIV><BR>Then next question is, how can I put the missing letters back on the front of these words?&nbsp; </DIV>  <DIV>&nbsp;</DIV>  <DIV>For this, I can use the "add-first-letter" function which I sent earlier to Matthias:</DIV>  <DIV>&nbsp;</DIV>  <DIV>(define (add-first-letter first-letter low)<BR>&nbsp; (cond <BR>&nbsp;&nbsp;&nbsp; [(empty? (rest low)) (cons (append (list first-letter) (first low)) empty)]<BR>&nbsp;&nbsp;&nbsp; [else (cons (append (list
 first-letter) (first low)) (add-first-letter first-letter (rest low)))]))</DIV>  <DIV>&nbsp;</DIV>  <DIV>Now, I can combine the two functions into a main function, "add-letter-plus-prefix":</DIV>  <DIV>&nbsp;</DIV>  <DIV>(define (add-letter-plus-prefix x a-word)<BR>&nbsp; (add-first-letter (first a-word) (Rest x a-word)))</DIV>  <DIV>&nbsp;</DIV>  <DIV>;example:</DIV>  <DIV>(add-letter-plus-prefix 'x (list 'w 'a 't 'e 'r))</DIV>  <DIV>;answer:</DIV>  <DIV>(list<BR>&nbsp;(list 'w 'x 'w 'a 't 'e 'r)<BR>&nbsp;(list 'w 'x 'a 't 'e 'r)<BR>&nbsp;(list 'w 'x 't 'e 'r)<BR>&nbsp;(list 'w 'x 'e 'r)<BR>&nbsp;(list 'w 'x 'r))</DIV>  <DIV>&nbsp;</DIV>  <DIV>It looks nice, but the word is still shrinking away.&nbsp; I have simply added the first letter to the beginning of all the words.&nbsp; My problem is still, how can I increment the prefix in order: 'w, 'a, 't, 'e, 'r?&nbsp; </DIV>  <DIV>&nbsp;</DIV>  <DIV>At this point, I think my problem is too many levels of abstraction.&nbsp; I
 think that you all can see the answer very clearly, but I can't visualize multiple recursive functions.&nbsp; The tables, etc have been extremely helpful for me to develop the individual functions.&nbsp; As far as the final solution, perhaps I don't have the ability to "see" it on that level of abstraction?</DIV></BLOCKQUOTE></DIV></BLOCKQUOTE>  <DIV><BR class=khtml-block-placeholder></DIV>  <HR SIZE=1>  You rock. That's why Blockbuster's offering you <A href="http://us.rd.yahoo.com/evt=47523/*http://tc.deals.yahoo.com/tc/blockbuster/text5.com">one month of Blockbuster Total Access</A>, No Cost.</BLOCKQUOTE></DIV><BR></BLOCKQUOTE><BR><p>&#32;
      <hr size=1>Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile. <a href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ "> Try it now.</a>