DrRacket is a racket


What a way to get people through their prejudices.

Change the name from Scheme to Racket and bank on people not having a history of being misinformed to believe Lisp and Scheme are dead.

They ain’t of course.  Been hanging on for a Renaissance.

Go figure functional languages have resurged.  You remember those.

Of course Erlang does Lisp (aka lfe).

But what ballsy misdirection. Just don’t call it Scheme no more no more, just don’t call it Scheme no more.

Still.

Bad form in the examples:

(define (reply-more s)
  (cond
     [(equal? “hello” (substring s 0 5))
       “hi!”]
     [(equal? “goodbye” (substring s 0 7))
       “bye!”]
     [(equal? “?” (substring s ( (string-length s) 1)))
       “I don’t know”]
     [else “huh?”]))
> (reply-more “hello racket”)
“hi!”
> (reply-more “goodbye cruel world”)
“bye!”
> (reply-more “what is your favorite color?”)
“I don’t know”
> (reply-more “mine is lime green”)
“huh?”

The problem being  the test for “?” and that one is forced to fall through the first two tests and so it cracks up when a string shorter than 5 char comes through as there is an overrange condition.

For example:

(reply-more “bug?”)
. . substring: ending index is out of range
ending index: 5
starting index: 0
valid range: [0, 4]
string: “bug?”
>

Still takes me back.  I did knock up a lisp interpreter in FORTH years ago … for the shear fun of it.

The safer version thus (forgive the loss of indenting):

(define (reply-more s)
  (cond
    [(equal? “?” (substring s ( (string-length s) 1)))  
      “I don’t know”]
     [(equal? “hello” (substring s 0 5))       
      “hi!”]
     [(equal? “goodbye” (substring s 0 7))
      “bye!”]
     [else “huh?”]))

> (reply-more “bug?”)
“I don’t know”

I will leave it to the reader to work out if there is a bug if a 6 character string is used.

Now why I like lisp/scheme/forth?  The same reason I like python.  Very productive code and test and code and test and code and test.

So, now I like Racket too.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: