我有
(setq l2 '(1 (2 b (c 1 b))(a (1 2) d)))
(defun drumuri (l3)
(cond ((atom l3) (cons l3 nil))
(t (append
(cons (car l3) nil)
(drumuri (cadr l3))
(cons (car l3) nil)
(drumuri (caddr l3))))))
(drumuri l2)
它给了我:
Break 2
[4]> DRUMURI
Break 2
[4]> (1 2 B 2 C 1 C B 1 A 1 2 1 NIL A D)
但是我需要:
((1 2 B)(1 2 C 1)(1 2 C B)(1 A 1 2)(1 A D))
好消息,我找到了一些答案:
(setq l2 '(1 (2 b (c 1 b))(a (1 2) d)))
( defun drumuri (l3)
( cond ( (atom l3) ( cons l3 nil))
(t (append ( cons ( car l3 ) nil)
(drumuri ( cadr l3) )))))
(drumuri l2)
答案是:
[1]>
(1 (2 B (C 1 B)) (A (1 2) D))
[2]>
DRUMURI
[3]>
(1 2 B)
接下来是第二个答案:
(defun drumuri (l4)
(cond ((atom l4)(cons l4 nil))
( t ( append (cons ( car l4)nil)
(drumuri ( caddr l4))))))
(drumuri l2)
答案是:
[1]>
(1 (2 B (C 1 B)) (A (1 2) D))
[2]>
DRUMURI
[3]>
(1 A D)
所以剩下的就是找到:
(1 2 C 1) (1 2 CB) (1 A 1 2)