高效查找表中重复元素及去重复
http://bbs.mjtd.com/forum.php?mo ... &fromuid=202795
(出处: 明经CAD社区)
- (defun delsame(l1 rcz / l2);;带容差去重(重复过的取第一次出现),有时处理坐标点需要考虑容差
- (while l1
- (setq l2(cons(car l1)l2)l1(vl-remove-if'(lambda (x)(equal(car l1)x rcz))(cdr l1))))
- (reverse l2))
- (defun delsames(l1 rcz / a l l2);;带容差去重(重复过的不出现),有时处理坐标点需要考虑容差
- (while(setq a(car l1)l2(vl-remove-if'(lambda (x)(equal a x rcz))(cdr l1)))
- (if(=(1+(length l2))(length l1))(setq l(cons a l)))
- (setq l1 l2))
- (if(=(1+(length l2))(length l1))(setq l(cons a l)))
- (reverse l))
|