我只是按照在SICP的3.3.3说明创建表。 我写的代码只是效果很好。
这里是code_0.scm:
#lang scheme
(require rnrs/base-6)
(require rnrs/mutable-pairs-6)
(define (make-table)
(list '*table*))
(define (assoc key records)
(cond ((null? records)
false)
((equal? key (caar records))
(car records))
(else
(assoc key (cdr records)))))
(define (insert! key value table)
(let ((record (assoc key (cdr table))))
(if record
(set-cdr! record value)
(set-cdr! table
(cons (cons key value)
(cdr table)))))
'OK)
(define (lookup key table)
(let ((record (assoc key (cdr table))))
(if record
(cdr record)
false)))
(define table (make-table))
(insert! 0 0 table)
(insert! 1 1 table)
(insert! 2 2 table)
此外,我要引用的表在其他文件库,所以我写了code_1.scm。
;加:我删除code_0的“#lang计划”在这个时候
code_1.scm:
#lang scheme/load
(load "code_0.scm")
(define table-0 (make-table))
(insert! 0 0 table-0)
(insert! 1 1 table-0)
(insert! 2 2 table-0)
编译错误显示:
0}}
这有什么错了这一切?
它对LIST该计划,DrRacket的问题,还是语言的版本/标准?