标签: common-lisp
EG。列表(A 1(B 2)(1 C 4)(D 1(6 F))((G 4)6))=> 6
答案 0 :(得分:3)
快速回答是:
(defun count-sublists (list) (if (listp list) (1+ (loop for el in list sum (count-sublists el))) 0))
只需遍历元素并递归计算所有列表。