开发者

Why does this work in DrRacket but not in Racket from the console

(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 开发者_StackOverflow中文版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

Why does this work in DrRacket but not in Racket from the console

Why does this work in DrRacket but not in Racket from the console


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜