INPUT:(A(B(d(E)(F)))(C)(K)) 我现在有两个功能,这给我的OUTPUT:如何在没有dolist的情况下在lisp中打印树,只有递归?
甲
乙
ç
ķ
乙
d
d
Ë
˚F
Ë
NIL
但是我需要输出这样的:
一个:BCK
B:d
C:
k:
d:电子网
E:
F:
或
一个
b】S K
d
电子网
(defun print-children (s)
(cond ((null (caar (cdr s))) nil)
(t (print (caar (cdr s))) (print-children (cdr s)))))
(defun print-tree (s)
(cond ((null s) nil)
((atom (car s)) (print (car s)) (print-children s) (print-tree (cdr s)))
(t (print-tree (car s)))))
我不明白这个问题。 '全部来自新线路' - 这是什么意思?您的问题缺乏预期输入和输出的有用示例。 –
@RainerJoswig改变了它,是更清晰的? – ninjaknight
@RainerJoswig新的堆栈,忘记添加所有的信息 – ninjaknight