我在这里为 SICP 试用这个“在线导师”:http://icampustutor.csail.mit.edu/6.001-public/tutor.cgi?op=registration- page
我正在查看以下问题:
假设我们已经评估了表格
(define thing (cons (cons (cons 1 nil) nil)
(cons (cons 2 (cons 3 (cons 4 nil)))
(cons 2
(cons 3 nil))))) Write expressions
仅使用 car、cdr 和 thing 其值是下面给出的列表结构。
(1)
1
(2 3)
(3)
我对最后一个有问题。我想出了一种使用反引号和取消引号的方法,但是在线教程不会接受答案。使用鸡计划的解释器:
#;3> (define nil '())
#;4> (define thing (cons (cons (cons 1 nil) nil)
---> (cons (cons 2 (cons 3 (cons 4 nil)))
---> (cons 2
---> (cons 3 nil)))))
#;5>
#;5> thing
(((1)) (2 3 4) 2 3)
#;25> `(,(car(cdr(car(cdr thing)))))
(3)
还有另一种方法可以做到这一点吗?