[英]Build number list - Scheme
I need to build a list like: (list (list 1 2) (list 3 4) (list 5 6))
, but there is an error in the following code: 我需要构建一个列表,如: (list (list 1 2) (list 3 4) (list 5 6))
,但是以下代码中有错误:
(define example
(lambda (a b)
(let ((tmp (+ b 1)))
(list '(1 b) '(2 tmp) '(3 3)))))
(example 1 4)
The result that I want is (list (list 1 4) (list 3 5) (list 3 3))
but the result I get: (list (list 1 'b) (list 2 'tmp) (list 3 3))
. 我想要的结果是(list (list 1 4) (list 3 5) (list 3 3))
但我得到的结果是:( (list (list 1 'b) (list 2 'tmp) (list 3 3))
。
You need to do 你需要做
(list (list 1 b) (list 2 tmp) '(3 3))
or 要么
(list `(1 ,b) `(2 ,tmp) '(3 3))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.