kkq0305 发表于 2021-7-29 12:41:15

对表进行特殊合并

;函数tt 对表进行特殊合并
;(tt '((1 2) (2 3) (3 4) (5 6) (6 5) (6 7))) 返回 ((1 4) (5 5) (6 7))
(defun tt (lst / f nlst)
(setq        f (lambda (x y)
          (if        (= (caar y) x)
              (f (cadar y) (cdr y))
              (list x y)
          )
          )
)
(if lst
    (cons (list (caar lst) (car (setq nlst (f (cadar lst) (cdr lst)))))
          (tt (cadr nlst))
    )
)
)
页: [1]
查看完整版本: 对表进行特殊合并