I'm still trying to understand exactly how this helps me:<br><br>(cond ((empty? a-word) (list (list a-letter)))<br>
(else<br>
; a-letter symbol 'x<br>
; a-word los (list 'a 'b 'c 'd)<br>
; (first a-word) symbol 'a<br>
; (rest a-word) los (list 'b 'c 'd)<br>
; (insert-everywhere a-letter (rest a-word)) lolos
(list (list 'x 'b 'c 'd) (list 'b 'x 'c 'd) (list 'b 'c 'x 'd) (list 'b
'c 'd 'x))<br>
; right answer lolos (list
(list 'x 'a 'b 'c 'd) (list 'a 'x 'b 'c 'd) (list 'a 'b 'x 'c 'd) (list
'a 'b 'c 'x 'd) (list 'a 'b 'c ' d 'x))<br>
)))<br><br>I see how when (rest a-word) is (list 'b 'c d), that (insert-everywhere a-letter (rest a-word)) is (list (list 'x 'b 'c 'd) (list 'b 'x 'c 'd) etc...), because this is what I've defined the function insert-everywhere to do. I think I understand what the next step is now, it's figuring out how to go from (list (list 'x 'b 'c 'd) etc...) to the right answer which is (list (list 'x 'a 'b 'c 'd) etc.<br>
<br>So, I have the following information/data available to me in order to do this:<br><br> ; a-letter symbol 'x<br>
; a-word los (list 'a 'b 'c 'd)<br>
; (first a-word) symbol 'a<br>
; (rest a-word) los (list 'b 'c 'd)<br><br>Am I thinking about this correctly?<br><br>At this point, it looks like in order to turn this:<br><br>(list (list 'x 'b 'c 'd) <br>
(list 'b 'x 'c 'd) <br> (list 'b 'c 'x 'd) <br> (list 'b
'c 'd 'x))<br><br>into this:<br><br>(list
(list 'x 'a 'b 'c 'd) <br> (list 'a 'x 'b 'c 'd) <br> (list 'a 'b 'x 'c 'd) <br> (list
'a 'b 'c 'x 'd) <br> (list 'a 'b 'c ' d 'x))<br><br>I have to <br>1. insert (first a-word) between 'x and 'b for the first list<br>2. insert (first a-word) in front of the rest of the lists<br>
<br>So, I potentially need some function that can prepend a symbol onto each word in a list of words.<br><br>; prepend-letter: Letter List-Of-Words -> List-Of-Words<br>; creates a List-Of-Words where a-letter is inserted before<br>
; each word in a-list-of-words<br>(define (prepend-letter a-letter a-list-of-words )<br> (cond <br> ((empty? a-list-of-words) empty)<br> (else (append (list (append (list a-letter) (first a-list-of-words)))<br> (prepend-letter a-letter (rest a-list-of-words))))))<br>
<br>is this prepend-letter function one of the helper functions I need? I'm starting to think I might be on the right track here. Completing the insert-everywhere function still eludes me, but maybe the helper-functions need to be written first before insert-everywhere will work correctly?<br>
<br>