<div>OK, here's a simple function that adds a letter to a word:</div> <div> </div> <div>(define (add-first-letter first-letter word)<BR> (append (list first-letter) word))</div> <div><BR>(add-first-letter 'A (list 'X 'T 'E))=(list 'A 'X 'T 'E')<BR></div> <div>So my question is, where does (list 'A 'T 'E) come from? In your table below, you say "the recursion: "X" "TE" --> "XTE" "TXE" "TEX". Actually I have never been able to create such a recursion. That's the big mystery to me. </div> <div> </div> <div>I just read Dave Yrueta's encouraging note, and he says I need to focus on your hint about adding 'A to the list, "in the simplest and most natural way." Well, all I can think of is to append it, like I did above. But there is no recursive element, and I cannot call it or plug it into the main recursive function. It is floating out in space.</div> <div><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></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>On Mar 28, 2008, at 11:51 AM, Cooke Kelsey wrote:<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></BLOCKQUOTE><BR><p> 
<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>