<div>Hi, I've made some progress but no jackpot yet...</div> <div> </div> <div>Here are the tables with all of the values, as you suggested:</div> <div> </div> <div>First Table: <BR> <BR> s | word | (first word) | (insert-in-single-word s (rest word)) | expected result for (insert-... s low)<BR> --------------------------------------------------------------------------------------------------------<BR> 'X |(list 'A 'T)| 'A | (list (list 'X 'T) (list 'T 'X)) | (list (list 'X 'A 'T) (list 'A 'X 'T) (list 'A 'T 'X))<BR> <BR> Table for Recursive Case:<BR> <BR> s | word | (first word) | (insert-in-single-word s (rest word)) | expected result for (insert-... s
low)<BR> --------------------------------------------------------------------------------------------------------<BR> 'X |(list 'T)| 'T | (list 'X) | (list (list 'X 'T) (list 'T 'X))<BR></div> <div> </div> <div>After examining the tables, I tried a couple of new ways to get the results in the last column. </div> <div> </div> <div>The easiest way was simply to append the letters in order, so that X, AT-->XAT, AXT ATX </div> <div> </div> <div>(define (insert-in-single-word2 s word)<BR>(list (append (list s) word) (append word (list s)) (append (list (first word)) (list s) (rest word))))</div> <div> </div> <div>This doesn't have any recursive part, so it only works on 3 letter words.</div> <div> </div> <div>When I tried to insert a recursive part, no matter how I arranged the parts, I always lost
letters. </div> <div> </div> <div>For instance, the definition below results in: X,AT-->XAT, ATX, X</div> <div> </div> <div>(define (insert-in-single-word s word)<BR> (cond<BR> [(empty? (rest word)) empty]<BR> [else (list (append (list s) word) (append word (list s)) (append (list s) (insert-in-single-word s (rest word))))]))<BR></div> <div><BR><BR><B><I>Matthias Felleisen <matthias@ccs.neu.edu></I></B> wrote:</div> <BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"> <div><BR>On Mar 27, 2008, at 3:15 PM, Cooke Kelsey wrote:<BR><BR>> (1) At this point it becomes critical to spell out the (list ...) <BR>> stuff, i.e., to turn the example into full-fledged Scheme data. <BR>> Small step.<BR>><BR>> (.......which Scheme displays as (cons (cons 'X (cons 'A (cons 'T <BR>> empty))) (cons (cons 'A (cons 'X (cons 'T empty))) (cons (cons 'A
<BR>> (cons 'T (cons 'X empty))) empty)))....)<BR><BR>I recommend raising the language level to Beginner with List ..<BR><BR><BR>> (4) And before you complete the template build a table just like <BR>> the one above for the recursive case.<BR>><BR>> First Table:<BR>><BR>> s | word | (first word) | (insert-in-single-word s (rest <BR>> word)) | expected result for (insert-... s low)<BR>> ---------------------------------------------------------------------- <BR>> ----------------------------------<BR>> 'X |(list 'A 'T)| 'A | (insert-in-single-word s <BR>> (list 'T) | (list (list 'X 'A 'T) (list 'A 'X 'T) (list 'A 'T 'X))<BR><BR><BR>What is the VALUE of (insert-in-single-word s (list 'T) ) ? The <BR>purpose statement tells you!</div> <div> </div> <div><BR><BR>> Table for Recursive Case:<BR>><BR>> s | word | (first word) | (insert-in-single-word s (rest <BR>> word)) | expected result for (insert-... s low)<BR>>
---------------------------------------------------------------------- <BR>> ----------------------------------<BR>> 'X |(list 'T)| 'T | (insert-in-single-word s empty <BR>> | (list (list 'X 'T) (list 'T 'X))<BR><BR>What is the VALUE of (insert-in-single-word 'X empty) ? The purpose <BR>statement tells you!</div> <div> </div> <div><BR>> I feel I am getting closer to the answer. The second table <BR>> suggest to me that there is something about recurring down to 2 <BR>> letters and then appending the rest on.....except that I lost the <BR>> rest of the letters.<BR><BR>Almost! You need to actually determine the value of these expressions <BR>not just write down the expressions to make the leap. You're almost <BR>there.<BR><BR>And don't forget: if the leap is to large, you may need yet another <BR>helper function.<BR><BR>-- Matthias<BR><BR><BR><BR></div></BLOCKQUOTE><BR><p> 
<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>