本帖最后由 llsheng_73 于 2014-5-7 08:49 编辑
 - (defun tt(a / ListAll b c d)
- (defun ListAll(tlst f / aaa lst);;f为t时全部压平,nil时保留一层
- (defun aaa (tlst)
- (foreach b tlst
- (if(if f(listp b)(and(listp b)(listp(car b))))(aaa b)(setq lst(cons b lst)))))
- (if(listp tlst)(if(setq lst (aaa tlst))(reverse lst))))
- (while a
- (setq b(car a)c nil)
- (while(setq b(vl-remove'nil(mapcar'(lambda(x)(assoc x a))(ListAll b t))))
- (foreach x b(setq a(vl-remove x a)))
- (setq c(if c(append c b) b)))
- (setq d(append d(list c))))
- d)
;;(tt '((6 7)(1 2)(3 4)(6 5)(2 3)(7 8)))
;;==>(((6 7) (7 8) (6 5)) ((1 2) (2 3) (3 4)))
|