明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1247|回复: 2

看看这个程序如何改

[复制链接]
发表于 2008-10-31 16:33:00 | 显示全部楼层 |阅读模式

这是个合并数据的小程序,运行后有数据重复,不知何故,请给看看,谢谢

(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) ))

发表于 2008-10-31 18:01:00 | 显示全部楼层
本帖最后由 作者 于 2008-10-31 18:03:09 编辑

;;不知道你的规律,这样行不?

(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)))

 楼主| 发表于 2008-11-3 18:27:00 | 显示全部楼层

谢谢!你的程序真简单,佩服

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-9-21 14:32 , Processed in 0.169215 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表