这是个合并数据的小程序,运行后有数据重复,不知何故,请给看看,谢谢 (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) )) |