移除表中重复项(适用于任何表)【能否在简化】
;测试(vl-removes '((2162.48 1434.06 0.0) (2433.05 1163.76 0.0) (2433.05 1163.76 0.0) (2433.05 1163.76 0.0)));测试(vl-removes (list 1 2 1 2 3))
;;;移除表中重复项
(defun vl-removes (lst)
(foreachX lst
(setq lst (append (vl-remove X lst) (list X)))
)
)
能否在简化或其他方法写更简单 (defun delsame (l)
(if l
(cons (car l) (delsame (vl-remove (car l) (cdr l)))
)
) Gu_xl 发表于 2012-12-15 11:36 static/image/common/back.gif
(defun delsame (l)
(if l
(cons (car l) (delsame (vl-remove (car l) (cdr l)))
好像没这个函数的说明啊delsame yanguangfei 发表于 2012-12-15 12:59 static/image/common/back.gif
好像没这个函数的说明啊delsame
这是函数调用自身完成循环。有点绕。 我的简单易懂
(defun T1 (Lst / LstNew)
(SETQ LstNew '())
(foreach _LstItem Lst
(if (not (member _LstItem LstNew))
(setq LstNew (CONS _LstItem LstNew))
)
)
LstNew
) 坐标点位就不好用! 本帖最后由 Gu_xl 于 2012-12-15 13:34 编辑
cable2004 发表于 2012-12-15 13:19 static/image/common/back.gif
坐标点位就不好用!
(defun DumpPt (l fuzz )
(if l
(cons (car l)
(DumpPt
(vl-remove-if '(lambda (x) (equal (car l) x fuzz)) (cdr l))
fuzz
)
)
)
) 拜读G的强大,套内套子程序不好理解。不过比我的简单! 递归啊,我什么时候可以明白你的心 如果处理数据量过大的化,过于简化和递归会让你的内存快速耗尽。
页:
[1]