<div>my base case the function should return a</div><div>list of words but before returned a single word.</div><div><br></div><div>Very good decision. Now take a close look at how you phrased the second condition. According to the design recipe, it should be structured to match the second condition of your data definition for list-of-words. Does it?</div>
<div><br></div><div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">(define (insert-everywhere/in-single-word s w)<br> (cond<br> [(empty? w) (list s)]<br>
<b>[else (list (list s (first w)) (cons (first w)<br>(insert-everywhere/in-single-word s (rest w))))]))</b></span></div><div><br></div><div><br></div><div><br><br><div class="gmail_quote">On Tue, Jul 6, 2010 at 3:14 PM, Sam Griff <span dir="ltr"><<a href="mailto:sgriff89@gmail.com">sgriff89@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">> Exercise 12.4.2 is notorius. When looking to (list 'a 'b 'c), you should<br>
> exspect 6 distinct permutations.<br>
> Jos<br>
<br>
</div>Thanks for your response but that really doesn't help me much. I'm<br>
focusing on insert-everywhere/in-single-word now. I understand what<br>
arrangements does<br>
and what permutations to expect.<br>
<div class="im"><br>
> My first suggestion is to check the function examples to make sure the values they expect are consistent with your data definitions.<br>
<br>
</div>Can you explain please? I'm not sure I fully understand. The only<br>
thing I could see was in my base case the function should return a<br>
list of words but before returned a single word. Is that what you<br>
mean?<br>
<div class="im"><br>
(define (insert-everywhere/in-single-word s w)<br>
(cond<br>
</div> [(empty? w) (cons (cons s empty) empty)]<br>
[else ... (first w) ... (insert-everywhere/in-single-word s (rest w))]))<br>
<div class="im"><br>
> Amen.<br>
><br>
> -- Make sure you truly understand list vs cons. If you have any doubts,<br>
> stick to cons.-- For your template, spell out what each expression produces<br>
> before you finish the definition.-- Use the examples, especially the ones<br>
> that fail.-- Figure out what you need to combine the pieces.-- Ideally,<br>
> arrange the thing in a table:<br>
> input | (first input) | .... | recursive result | expected result<br>
><br>
> and keep adding examples until it clicks: i.e., until you know how to<br>
> combine recursive result with some other things to get the expected result.<br>
><br>
> And do stick to the design recipe all the way down.<br>
<br>
</div>Thanks! I will try those suggestions and see if they help.<br>
<div><div></div><div class="h5">_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
</div></div></blockquote></div><br></div>