有一个点列表,已知一个点的Y值,如何把该列表中的这个点坐标找出来?
本帖最后由 suiran 于 2024-5-14 15:24 编辑有一个点列表,已知一个点的Y值,如何把该列表中的这个点坐标找出来?
((10 16577.9 668.358) (10 19511.2 667.123) (10 19397.5 -1787.44) (10 15759.4 -1787.39) (10 15895.8 -627.732))
比如我想找出Y值为667.123的这个点的坐标。
(DEFUN LH:ASSOCY (Y LST)
(REVERSE (ASSOC Y (MAPCAR 'REVERSE LST)))
)
(SETQ LST '((10 16577.9 668.358)
(10 19511.2 667.123)
(10 19397.5 -1787.44)
(10 15759.4 -1787.39)
(10 15895.8 -627.732)
)
Y 667.123
PP(LH:ASSOCY Y LST)
) (defun c:tt ()
(setq lst '((10 16577.9 668.358) (10 19511.2 667.123) (10 19397.5 -1787.44) (10 15759.4 -1787.39) (10 15895.8 -627.732)))
(setq lst(mapcar '(lambda(x)(list(cadr x)(caddr x)))lst))
(setq a 667.123)
(setq newlst(vl-remove-if-not '(lambda(x)(equal a(cadr x)0.01))lst))
(princ newlst)
(princ)
)
aws 发表于 2024-5-14 16:16
(defun c:tt ()
(setq lst '((10 16577.9 668.358) (10 19511.2 667.123) (10 19397.5 -1787.44) (10 157 ...
感谢!!!! liuhe 发表于 2024-5-14 15:29
感谢回复!! (defun c:tt ()
(setq lst '((10 16577.9 668.358) (10 19511.2 667.123) (10 19397.5 -1787.44) (10 15759.4 -1787.39) (10 15895.8 -627.732)))
(setq a 667.123)
(mapcar '(lambda (x)(if (= a(caddr x))(setq lis x)))lst)
(print lis)
)
aws 发表于 2024-5-14 16:16
(defun c:tt ()
(setq lst '((10 16577.9 668.358) (10 19511.2 667.123) (10 19397.5 -1787.44) (10 157 ...
YOUXIU:lol
页:
[1]