<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div><br></div><div>Okay you have gotten to the point where you're jumping even faster. Slogan: </div><div><br></div><div> furiously fast programming leads to nowhere. </div><div><br></div><div>;; --- </div><div><br></div><div>All I was getting at is a simple point: </div><div><br></div><div>Your recursive calls in insert-everywhere/one-word produced almost all the work in the recursion. Indeed, it always produces all but one word, except that the first letter from the original word is missing. Example: </div><div><br></div><div> given: the recursion in the final result I want plus </div><div> 'X "ATE" "X" "TE" --> "XTE" "TXE" "TEX" "AXTE" "ATXE" "ATXE" "ATEX" "XATE" </div><div><br></div><div>Given the recursive result (the list of words that are too short by the first letter in the orginal word) can you design a function that adds this letter (no matter what it is) to the front of all these words you have gotten back? </div><div><br></div><div>DONE? </div><div><br></div><div>After that: what is missing? </div><div><br></div><div>-- Matthias</div><div><br></div><div><br></div><div><br></div><div><br></div><br><div><html>On Mar 28, 2008, at 11:51 AM, Cooke Kelsey wrote:</html><br class="Apple-interchange-newline"><blockquote type="cite"><div>OK, that helps me a little. If I insert "cons (first word)," then I can rebuild the word:</div> <div> </div> <div>(define (cons-function word)<br> (cond<br> [(empty? (rest word)) word]<br> [else (cons (first word) (cons-function (rest word)))]))</div> <div> </div> <div>(cons-function (list 'A 'T 'W)) = (list 'A 'T 'W)</div> <div> </div> <div>The problem is how to add this to a shrinking function:</div> <div> </div> <div>(define (shrinking-function s word)<br> (cond<br> [(empty? (rest word)) empty]<br> [else (list (append (list s) word) (shrinking-function s (rest word)))]))<br></div> <div>(This shrinking function isn't exactly what I want, but at least it gives me (list 'X 'A 'T 'W) and (list 'X 'T 'W)).</div> <div> </div> <div>So I append them together: </div> <div> </div> <div>(append (cons-function (list 'A 'T 'W)) (shrinking-function 'X (list 'A 'T 'W)))</div> <div> </div> <div>And I get this:</div> <div> </div> <div>(list (list 'X 'A 'T 'W) (list (list 'X 'T 'W) empty)) (list 'A 'T 'W (list 'X 'A 'T 'W) (list (list 'X 'T 'W) empty))</div> <div> </div> <div>Garbage!</div> <div> </div> <div>As a last resort, I try to combine cons and shrinking functions together:</div> <div> </div> <div>(define (cons+shrinking-function s word)<br> (cond<br> [(empty? (rest word)) word]<br> [else (append (cons (first word) (cons+shrinking-function 'X (rest word))) (list s) (rest word))]))</div> <div> </div> <div>(cons+shrinking-function 'X (list 'A 'T 'W)) = (list 'A 'T 'W 'X 'W 'X 'T 'W)</div> <div> </div> <div>It looks kind of nice, but it is even further from the expected result.</div> <div> </div> <div><br><b><i>Matthias Felleisen <<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"> <div><br></div> <div>How about (cons 'A (list 'X 'T)) = (list 'A 'X 'T)</div> <div><br></div> <div><br></div> <div><br></div><br> <div>On Mar 28, 2008, at 10:53 AM, Cooke Kelsey wrote:<br class="Apple-interchange-newline"> <blockquote type="cite">(append (list 'A) (list 'X 'T)) = (list 'A 'X 'T)<br><br><b><i>Matthias Felleisen <<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>></i></b> wrote: <blockquote class="replbq" style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"> <div><br></div> <div>Here is a definition of 'adding in the missing element': </div> <div><br></div> <div>* If a list X misses the symbol 'A (at the front), how do you get a list that has the 'A and all of X? </div> <div><br></div> <div>* X = (list 'X 'T) and 'A --> I want (list 'A 'X 'T). How do I do that? </div> <div><br></div> <div>-- Matthias</div> <div><br></div></blockquote> <div><br class="khtml-block-placeholder"></div> <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></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>