2
(define pick
    (lambda (num lat)
      (cond ((null? lat) (quote()))
            ((= (sub1 num) 0) (car lat))
            (else 
                  (pick (sub1 num) (cdr lat))))))
(define brees (quote (a b c d e touchdown g h i)))
(pick 6 brees)

The language in DrRacket is set to Advanced Student. It also works fine in the IronScheme console after defining sub1.

The error message is:

reference to undefined identifier: R

alt text alt text

eric.christensen
  • 3,191
  • 4
  • 29
  • 35
  • I assume that these are separate runs. I would make sure that you have the latest version of racket, and if it persists, ask on the plt mailing list or file a bug. The PLT people are about as responsive a crowd as you will find. Your crash is occuring in the REPL code, but I have no idea where R comes from. – deinst Jul 23 '10 at 23:06
  • Thanks for your help. I'll do a bit more research and then ask the PLT people if I can't figure it out. – eric.christensen Jul 23 '10 at 23:30

1 Answers1

2

When I type this into the console I get

Welcome to Racket v5.0.
> (define pick
    (lambda (num lat)
     (cond ((null? lat) (quote()))
        ((= (sub1 num) 0) (car lat))
        (else
              (pick (sub1 num) (cdr lat))))))
> (define brees (quote (a b c d e touchdown g h i)))
> (pick 6 brees)
'touchdown

How are you running this in the console? If you are loading it, you may need a #lang Racket for the first line.

deinst
  • 18,402
  • 3
  • 47
  • 45
  • I don't know what I was doing wrong. It seems to work now. I was just running Racket on windows by running racket.exe and entering everything into the REPL. Weird. Thanks. – eric.christensen Jul 23 '10 at 19:40
  • 1
    I cannot find where I've seen this, but I think racket uses by default the latest #lang you've used in the past. That may explain this erratic behavior. – Thaddee Tyl Jul 15 '11 at 11:19