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)

DrRacket 中的语言设置为高级学生。在定义sub1.

错误信息是:

reference to undefined identifier: R

替代文字 替代文字

4

1 回答 1

2

当我在控制台中输入这个时,我得到

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

你是如何在控制台中运行它的?如果要加载它,#lang Racket则第一行可能需要一个。

于 2010-07-23T19:27:13.233 回答