【发布时间】:2020-03-28 08:06:59
【问题描述】:
我只被允许使用do 构造,我仍然无法理解这个概念。我尝试了以下代码,但它返回nil。
(defun fun(list)
(do ((i 0 (+ i 1)) (l '() (if (listp (nth i list)) (append l (list (length (nth i list)))))))
((null (nth i list)) l)
)
)
l的更新值有错吗?此列表(a (b) (c d)) 的输出应为(1 2)。
【问题讨论】:
-
不,
(fun '(a (b) (c d)))返回(1 2)。
标签: list lisp common-lisp nested-lists do-loops