(SETQ LL '((10 20) (5 40) (10 30) (20 40) (10 40)) l nil)
(VL-REMOVE-IF-not '(lambda(x) (if (not (member (cadr x) l)) (setq l (cons (cadr x) l)))) ll) baitang36 发表于 2024-7-3 09:26
应该搞一个竞赛,看谁能用最短的代码实现。当前是lijiao的
(SETQ LL '((10 20) (5 40) (10 30) (20 40) (1 ...
最快才有意义 本帖最后由 啵浪鼓 于 2024-7-13 21:42 编辑
((10 20 2) (20 30 3) (10 20 5) (20 30 1) (20 30 2))
满足x和y坐标相同条件,求xy相同组成一块返回
( ((10 20 2)(10 20 5))((20 30 3) (20 30 1) (20 30 2)) )
本帖最后由 yoyoho 于 2024-7-15 19:21 编辑
啵浪鼓 发表于 2024-7-13 21:15
((10 20 2) (20 30 3) (10 20 5) (20 30 1) (20 30 2))
满足x和y坐标相同条件,求xy相同组成一块返回
;|
满足x和y坐标相同条件,求xy相同组成一块返回
(setq qq '((10 20 2) (20 30 3) (10 20 5) (20 30 1) (20 30 2) (10 500 4) (90 500 10) (100 500 400)))
(reverse (SORT-SAME-XY qq))
(((10 20 2) (10 20 5)) ((20 30 3) (20 30 1) (20 30 2)) ((10 500 4)) ((90 500 10)) ((100 500 400)))
|;
(defun sort-same-xy (l / lst l1 a)
(while l
(setq a (car l)
l (cdr l)
l1(vl-remove-if '(lambda (e) (or (/= (car e)(car a)) (/= (cadr e)(cadr a))) ) l)
lst (cons (cons a l1) lst)
l1 nil
l(vl-remove-if '(lambda (e) (and (= (car e)(car a)) (= (cadr e)(cadr a)) ) ) l)
))
lst)
页:
1
[2]