Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
小schemer drracket错误无法在标识符定义之前引用标识符_Racket_The Little Schemer - Fatal编程技术网

小schemer drracket错误无法在标识符定义之前引用标识符

小schemer drracket错误无法在标识符定义之前引用标识符,racket,the-little-schemer,Racket,The Little Schemer,初级问题, 刚开始编写小schemer手册,并在我的macbook上安装了DrRacket来尝试一些代码示例 如果我选择Racket语言,下面的代码 #lang Racket (define (atom? x) (and (not (pair? x)) (not (null? x)))) (atom? '()) (define lat? (lambda (l) (cond ((null? l) #t) ((

初级问题, 刚开始编写小schemer手册,并在我的macbook上安装了DrRacket来尝试一些代码示例

如果我选择Racket语言,下面的代码

 #lang Racket

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

(atom? '()) 



(define lat?
    (lambda (l)
        (cond
            ((null? l) #t)
            ((atom? (car l)) (lat? (cdr l)) )
            (else #f))))
(lat? (a b))       
将触发错误消息:

a: unbound identifier in module in: a
如果我选择R5RS语言

#lang R5RS

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

(atom? '()) 



(define lat?
    (lambda (l)
        (cond
            ((null? l) #t)
            ((atom? (car l)) (lat? (cdr l)) )
            (else #f))))
(lat? (a b))  
我收到一条错误消息:

#%plain-module-begin: illegal use (not a module body) in: (#%plain-module-begin (module configure-runtime racket/base (require r5rs/init)) (define (atom? x) (and (not (pair? x)) (not (null? x)))) (atom? (quote ())) (define lat? (lambda (l) (cond ((null? l) #t) ((atom? (car l)) (lat? (cdr l))) (else #f)))) (lat? (a b))) 
有人知道我做错了什么吗


谢谢

看来最后一个电话应该是

(lat? '(a b))
。。。没有


(另外:我建议一般使用#lang racket,但我强烈怀疑R5RS出现问题是因为您“设置了两次语言”;如果使用#lang R5RS启动程序,则无需更改语言级别。相反,如果设置语言级别,则不应使用#lang R5RS启动程序。如果同时使用#lang R5RS启动程序,我猜您会看到错误消息。)

看起来最后一次调用应该是

(lat? '(a b))
。。。没有


(另外:我建议一般使用#lang racket,但我强烈怀疑R5RS出现问题是因为您“设置了两次语言”;如果您使用#lang R5R启动程序,则无需更改语言级别。相反,如果您设置语言级别,则不应使用#lang R5R启动程序。如果您同时使用#lang R5R启动程序,我猜您会收到您看到的错误消息。)

我在使用racket的小阴谋家中遇到了类似的问题,并找到一条有用的评论-基本上,使用
enter
我也遇到了类似的问题,通过racket查看了小阴谋家,发现了一条有用的评论——基本上,使用
enter