[racket] Fwd: Basic inquiry

From: saad bashir (bashir.saad at gmail.com)
Date: Mon May 14 12:11:23 EDT 2012

---------- Forwarded message ----------
From: saad bashir <bashir.saad at gmail.com>
Date: Mon, May 14, 2012 at 7:08 PM
Subject: Re: [racket] Basic inquiry
To: Matthias Felleisen <matthias at ccs.neu.edu>

Dear Matthias,

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.

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.

Thank you.


On Mon, May 14, 2012 at 5:53 PM, Matthias Felleisen <matthias at ccs.neu.edu>wrote:

> On May 13, 2012, at 1:53 AM, saad bashir wrote:
>  Now it seems that the text is assuming something that I  do not know.
> Sorry for your difficulties. The text isn't assuming knowledge at all. It
> does assume that you read the Help Desk for functions that have no
> description in the text, for example, substring. But these are linked to
> the Help Desk to make life easy.
> It does assume a desire to play at the interactions panel. For example,
> when it says
>    -
>    string-ith<http://pre.acket-lang.org/docs/html/htdp-langs/beginner.html#(def._(lib._htdp-beginner..rkt._lang)._((lib._lang%2Fhtdp-beginner..rkt)._string-ith))> consumes
>    a string s and extracts the one-character substring located at the ith
>    position (counting from 0);
> you should understand the following, based on your experience with sqrt
> and sqr:
>  -- the function is applied to a string and a number i
> [[ I see how the second part isn't spelled out and I will fix this
> immediately.
>     Thanks for pointing it out, even if only implicitly. ]]
>  -- it returns a string
> It does not assume you truly understand what it produces though I'd hope
> it's
> clear. From your experience with sqrt, I would hope you'd enter
>  > (string-ith "some string" 8)
> or
>   > (string-ith "some string" 0)
> or even
>   > (string-ith "some string" -33)
> and then to infer what it does.
> Next, the exercises as of mixing it up assume that you are willing to play
> with the composition of functions or equally the nesting of expressions.
> See exercise 4.
> Since the exercise clearly requests breaking up the string into pieces,
> you need
> substring. So start by experimenting with substring:
>   > (substring str 0 i)
>  "hello"
> Now that's a great start. You have the first part of the desired output.
>  > (substring str i 8)
>  "wor"
>  > (substring str i 10)
>  "world"
>  > (substring str i 20)
>  substring: ending index 20 out of range [5, 10] for string: "hello world"
> The second experiment gives you the second part of the desired output.
> Okay, now we need to piece together these two pieces and a _ in between:
>  (define str "helloworld")
>  (define i 5)
>  (string-append (substring str 0 i) "_" (substring str i 10))
> This is what I have in my Definitions Window. I click Run and it works.
> Finally, change the str definition to
>  (define str "Saad is learning to program and it is working")
> Run the program. See whether you still get what you want. You don't.
> The "10" should definitely trouble you. Because it is special to hello
> world.
> So try to find an expression that will replace it for arbitrary str
> strings.
> Helps? -- Matthias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120514/dac58311/attachment.html>

Posted on the users mailing list.