![]() |
看看这个程序如何改
看看这个程序如何改
www.dimcax.com 看看这个程序如何改 这是个合并数据的小程序,运行后有数据重复,不知何故,请给看看,谢谢 (setq jd '((245400.0 -1.38 -7.43) (245450.0 -1.28 -7.61)) lj '((245400.0 -35.3 35.1) (245450.0 -34.9 36.4)) ) ;(defun wh-jl (jd lj) (setq lst '()) (foreach n jd ;外循环 (progn (setq tmp '()) (foreach m lj ;内循环 (if (<= (abs (- (car m) (car n))) 0.5 ) (progn (setq temp1_y (cdr n)) (setq temp2_y (cdr m)) (setq i 0) (setq lst_1 '()) (repeat (length temp1_y) (setq temp1_y1 (nth i temp1_y)) (setq ii 0) (repeat (length temp2_y) (setq temp2_y1 (nth ii temp2_y)) (setq temp3_y (list temp2_y1 temp1_y1 )) (setq lst_1 (append lst_1 (list temp3_y))) (setq ii (1+ ii)) );repeat (setq i (1+ i)) );repeat );progn );if (setq tmp (append lst_1 tmp)) );foreach (if tmp (setq lst (cons (cons (car n) tmp) lst)) ) ) ) (setq lst (reverse lst)) ) 运行结果:((245400.0 (-35.3 -1.38) (35.1 -1.38) (-35.3 -7.43) (35.1 -7.43) (-35.3 -1.38) (35.1 -1.38) (-35.3 -7.43) (35.1 -7.43)) (245450.0 (-34.9 -1.28) (36.4 -1.28) (-34.9 -7.61) (36.4 -7.61) (-35.3 -1.38) (35.1 -1.38) (-35.3 -7.43) (35.1 -7.43))) 我要的结果:((245400.0 (-35.3 -1.38) (35.1 -1.38) (-35.3 -7.43) (35.1 -7.43) ) (245450.0 (-34.9 -1.28) (36.4 -1.28) (-34.9 -7.61) (36.4 -7.61) )) d ;;不知道你的规律,这样行不? (defun test (a b) (mapcar '(lambda (x y) (if (equal (car x) (car y) 0.00001) (cons (car x) (mapcar '(lambda (x y / n) (list x y)) (append (cdr y) (cdr y)) (list (cadr x) (cadr x) (caddr x) (caddr x)) ) ) ) ) a b ) ) (test jd lj)---> ((245400.0 (-35.3 -1.38) (35.1 -7.43) (-35.3 -7.43) (35.1 -1.38)) (245450.0 (-34.9 -1.28) (36.4 -7.61) (-34.9 -7.61) (36.4 -1.28))) d 谢谢!你的程序真简单,佩服 d |
| 所有的时间均为北京时间。 现在的时间是 01:20 AM. |