Hi Grant --<div><br></div><div>A few suggestions:</div><div><br></div><div>First, if you use the list function, make sure your data definitions for word and list-of-word use them too. More than any other problem I've encountered so far in HtDP, the interactions between contracts and data definition are what drive the design decisions that ultimately lead to the successful solution of this exercise. </div>
<div><br></div><div>Second, when formulating the data definition for list-of-words, consider the data-definition for 'polygons' in section 12.3.</div><div><br></div><div>Third, if you are thinking about introducing a third variable into one of the auxiliary functions, as this suggests <span class="Apple-style-span" style="border-collapse: collapse; color: rgb(80, 0, 80); "> (insert-everywhere-h char word 0)), </span><span class="Apple-style-span" style="border-collapse: collapse; ">don't. I made a similar mistake and it cost me dearly! Always refer to the template for structural recursion when designing </span><span class="Apple-style-span" style="border-collapse: collapse;">auxiliary functions, which I think can be summed up as (first a-list).... (recursive-function (rest a-list)). Stick to that structure, and allow the data definitions and contracts to guide the function design.</span></div>
<div><br></div><div>Hope that helps! Good luck!</div><div><br></div><div>Dave Yrueta</div><div><div><br><div class="gmail_quote">On Sat, Apr 4, 2009 at 10:04 AM, Marco Morazan <span dir="ltr"><<a href="mailto:morazanm@gmail.com">morazanm@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">><br>
> The thing is that I ignored what I saw and defined (insert-everywhere<br>
> char word) first:<br>
><br>
> (define (insert-everywhere char word)<br>
> (insert-everywhere-h char word 0))<br>
><br>
> ; insert-everywhere-h : symbol word integer -> list-of-words<br>
> ; to generate a list-of-words by inserting char into<br>
> ; word in every possible position<br>
><br>
> This function is like the insert functions in this chapter, and stops<br>
> when it reaches the length of the word (which is the last position).<br>
<br>
</div>Hmmm....what is the role of that integer? Do you really need it? If<br>
the integer is redundant get rid of it and eliminate that helper<br>
function (i.e. the *-h function).<br>
<br>
My suggestions:<br>
<br>
1. Start with the template for functions on words.<br>
2. Ask yourself:<br>
a. What do you expect from (insert-everywhere-h char (rest word))?<br>
b. What is missing from your answer to a.<br>
c. How do you build the needed answer from (first word) and the answer to a.<br>
<br>
Keep in mind that if you need to build a result of arbitrary length<br>
for c, then you probably want to design an auxilary function to do<br>
that.<br>
<br>
--<br>
<br>
Cheers,<br>
<font color="#888888"><br>
Marco<br>
</font><div><div></div><div class="h5">_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
</div></div></blockquote></div><br></div></div>