Little Schemer and Racket
Asked Answered
E

4

32

I'm starting to read the Little Schemer and now instead of PLT Scheme we have Racket. I would like to know if Racket is suitable for doing the exercises in the book or do I need to get another true Scheme compiler. Before I forgot to tell you, my OS is Windows x64.

The book, language and paradigm is complex enough, I would love to avoid struggling with a compiler.

Enfleurage answered 22/10, 2012 at 1:14 Comment(0)
M
39

DrRacket is the (r)evolution of DrScheme; DrRacket will work perfectly for the exercises in "The Little Schemer". Just don't forget to:

  1. In the Language dialog, choose "Use the language declared in the source"
  2. Write #lang racket at the top of each file you create
  3. Implement the atom? predicate in each file as explained at the very beginning of the book
  4. If you're going to re-implement an existing procedure, do so in a separate tab or window, because trying to rewrite a procedure in the edit window will result in a duplicate definition for identifier error. If necessary, use several files for saving the procedure definitions
Maidie answered 22/10, 2012 at 1:39 Comment(2)
Con mucho gusto! Acabo de editar mi respuesta, tiene varios tips adicionales para usar DrRacket con The Little SchemerUlaulah
I've been using racket, but I note that I have to change all the examples to include quote. Like you can't just enter (coffee cup tea cup and hick cup), it has to be '(coffe cup tea cup and hick cup), with the leading quote.Perfective
T
9

You really just need the atom? function. What’s described in the book's preface is essentially:

(define (atom? x)
  (and (not (pair? x)) (not (null? x))))

As mentioned, it should satisfy this test:

(atom? '()) ;=> #f

Note that there is also a definition in Racklog that will not satisfy that test.

A more detailed discussion on atom? is here.

Despite the book's suggestion to implement add1 and sub1, Racket does already provide them.

BTW, I use Vim for editing Racket, but a few other editors are capable.

Tonsillectomy answered 19/8, 2015 at 18:24 Comment(1)
Not sure; probably no relevance. I just stumbled across it while looking for an atom? func. Was easy to try out but saw that it wouldn't work, so thought worth the warning.Tonsillectomy
T
7

I have had the author of the book as a professor. He now uses Racket himself, but he uses Emacs as a text editor.

Trimetrogon answered 11/7, 2014 at 12:58 Comment(0)
C
2

Racket/Scheme are interchangeable. You should be able to answer any exercise with it. Good luck.

Also, I recommend downloading Dr. Racket as your interpreter.

Cotquean answered 22/10, 2012 at 1:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.