本帖最后由 gaics 于 2023-8-15 13:48 编辑
保留完全相同的元素
- (defun c:t8 (/ d e e2 waco i)
- (setq waco '((0 1 1)(1 1 1)(3 2 2)(5 3 3)(9 1 4)(10 2 4)(12 1 5)))
- (setq waco (vl-sort waco '(lambda (s1 s2) (< (car s1) (car s2)))))
- (setq d 0)
- (while (< d (length waco))
- (setq e (nth d waco))
- (setq i 0)
- (while (< i (length waco))
- (if (and (= (+ (car e) (cadr e)) (car (nth (+ d i 1) waco)))
- (= (caddr e) (caddr (nth (+ d i 1) waco)))
- )
- (progn
- (setq e2 (list (car e)(+ (cadr e)(cadr (nth (+ d i 1) waco)))(caddr e)))
- ;;(setq waco (subst e2 e (vl-remove (nth (+ d i 1) waco) waco)))
- (setq waco (subst e2 e (BF-List-RemoveIndex waco (+ d i 1))))
- (setq e e2)
- )
- (setq i (1+ i))
- )
- )
- (setq d (1+ d))
- )
- (print waco)
- (setq waco (vl-sort waco '(lambda (s1 s2) (< (car s1) (car s2)))))
- (princ)
- )
- (defun BF-List-RemoveIndex (lst index / i)
- (setq i -1)
- (vl-remove-if '(lambda (x) (= (setq i (1+ i)) index)) lst)
- )
|