对于((1 2) (3 4) (5 6))
,您可以使用loop for (a b) in '((1 2) (3 4) (5 6))
每次获得a = 1,b = 2。
但对于'(1 2 3 4)
,我尝试loop for x on '(1 2 3 4) by #'cddr for a = (car x) for b = (cadr x)
得到a = 1,b = 2.
有没有更好的方法来做这件事?
答案 0 :(得分:7)
尝试for ... on
:
(loop for (a b) on '(1 2 3 4) by #'cddr collect (cons a b))