<div dir="ltr"><br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">saad bashir</b> <span dir="ltr">&lt;<a href="mailto:bashir.saad@gmail.com">bashir.saad@gmail.com</a>&gt;</span><br>
Date: Mon, May 14, 2012 at 7:08 PM<br>Subject: Re: [racket] Basic inquiry<br>To: Matthias Felleisen &lt;<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>&gt;<br><br><br><div dir="ltr">Dear Matthias,<div><br></div>
<div>I apologize for what you took as a criticism of the text. It was not meant to be, rather an admission of my own shortcoming.  The book is superb and starts at a really basic level explaining and teaching computer science in the purest shorn of all paraphernalia.  I think it is great and consider myself lucky to have been led to it.  I will persist. I am getting better results and your detailed help below is great.  I will finish the book and hope will become a good and useful programmer.</div>

<div><br></div><div>Once again I am in awe of your commitment to teaching programming and the fact that despite having, I am sure, thousands of learners and  doing a huge number of really innovative things you still take time out to help someone like me.</div>

<div><br></div><div>Thank you.</div><span class="HOEnZb"><font color="#888888"><div><br></div></font></span><div><span class="HOEnZb"><font color="#888888">Saad   </font></span><div><div class="h5"><br><br><div class="gmail_quote">
On Mon, May 14, 2012 at 5:53 PM, Matthias Felleisen <span dir="ltr">&lt;<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br><div><div>On May 13, 2012, at 1:53 AM, saad bashir wrote:</div><br>
<blockquote type="cite"><span style="border-collapse:separate;font-family:&#39;Lucida Grande&#39;;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium"> Now it seems that the text is assuming something that I  do not know.  </span></blockquote>

</div><br><div><br></div></div><div>Sorry for your difficulties. The text isn&#39;t assuming knowledge at all. It</div><div>does assume that you read the Help Desk for functions that have no</div><div>description in the text, for example, substring. But these are linked to</div>

<div>the Help Desk to make life easy. </div><div><br></div><div>It does assume a desire to play at the interactions panel. For example, </div><div>when it says </div><div><div><div><blockquote type="cite"><span style="font-family:serif"><ul>

<li><p style="display:block;margin-top:1em;margin-right:0px;margin-bottom:1em;margin-left:0px"><span style="font-family:monospace;white-space:inherit;color:rgb(38,38,128)"><a href="http://pre.acket-lang.org/docs/html/htdp-langs/beginner.html#(def._(lib._htdp-beginner..rkt._lang)._((lib._lang%2Fhtdp-beginner..rkt)._string-ith))" style="text-decoration:none;color:blue" target="_blank">string-ith</a></span> consumes a string <span style="font-family:monospace;white-space:inherit;color:rgb(38,38,128)">s</span> and extracts the one-character substring located at the <span style="font-family:monospace;white-space:inherit;color:rgb(38,38,128)">i</span>th position (counting from 0);</p>

</li></ul></span></blockquote></div></div><div>you should understand the following, based on your experience with sqrt and sqr: </div></div><div> -- the function is applied to a string and a number i </div><div><span style="white-space:pre-wrap">        </span>[[ I see how the second part isn&#39;t spelled out and I will fix this immediately. </div>

<div><span style="white-space:pre-wrap">        </span>   Thanks for pointing it out, even if only implicitly. ]]</div><div><br></div><div> -- it returns a string</div><div><br></div><div>It does not assume you truly understand what it produces though I&#39;d hope it&#39;s </div>

<div>clear. From your experience with sqrt, I would hope you&#39;d enter </div><div><br></div><div> &gt; (string-ith &quot;some string&quot; 8) </div><div><br></div><div>or </div><div><br></div><div>  &gt; (string-ith &quot;some string&quot; 0)</div>

<div><br></div><div>or even </div><div><br></div><div>  &gt; (string-ith &quot;some string&quot; -33)</div><div><br></div><div>and then to infer what it does. </div><div><br></div><div>Next, the exercises as of mixing it up assume that you are willing to play</div>

<div>with the composition of functions or equally the nesting of expressions. See exercise 4. </div><div>Since the exercise clearly requests breaking up the string into pieces, you need </div><div>substring. So start by experimenting with substring: </div>

<div><br></div><div>  &gt; (substring str 0 i)</div><div> &quot;hello&quot;</div><div><br></div><div>Now that&#39;s a great start. You have the first part of the desired output. </div><div><br></div><div> &gt; (substring str i 8)</div>

<div> &quot;wor&quot;</div><div> &gt; (substring str i 10)</div><div> &quot;world&quot;</div><div> &gt; (substring str i 20)</div><div> substring: ending index 20 out of range [5, 10] for string: &quot;hello world&quot;</div>

<div><br></div><div>The second experiment gives you the second part of the desired output. </div><div><br></div><div>Okay, now we need to piece together these two pieces and a _ in between: </div><div><br></div><div> (define str &quot;helloworld&quot;)</div>

<div> (define i 5)</div><div> (string-append (substring str 0 i) &quot;_&quot; (substring str i 10))</div><div><br></div><div>This is what I have in my Definitions Window. I click Run and it works. </div><div><br></div><div>

Finally, change the str definition to </div><div><br></div><div> (define str &quot;Saad is learning to program and it is working&quot;)</div><div><br></div><div>Run the program. See whether you still get what you want. You don&#39;t. </div>

<div>The &quot;10&quot; should definitely trouble you. Because it is special to hello world. </div><div>So try to find an expression that will replace it for arbitrary str strings. </div><div><br></div><div>Helps? -- Matthias</div>

<div><br></div><div><br></div><div><br></div></div></blockquote></div><br></div></div></div></div>
</div><br></div>