明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2044|回复: 16

[已解答] 用vl-remove-if 写个去除祖玛enlist的第1-4个元素,谢谢大侠

[复制链接]
发表于 2015-1-29 21:39:18 | 显示全部楼层 |阅读模式
我想删除祖玛表的第1-4个元素,用vl-remove-if来一句话写,但是自己没整出来,只好到明经求助了。。

(setq a (list 1 2 3 4))
(vl-remove-if '(lambda (x) ...... enlist)
后面就不会了。。。。
发表于 2015-1-29 22:57:47 来自手机 | 显示全部楼层
cddddr 试试呗
 楼主| 发表于 2015-1-29 23:01:01 | 显示全部楼层
楼上能帮我写一下吗?
或者不用vl-remove-if,能实现我的所要的删除表中指定位置的元素,指定位置是多个,在一个表内list0内,如
(2 3 7 11),删除表的第2、3、7、11号元素(我知道表是从0开始算的),怎么解决?

代码希望尽量简捷一点,
发表于 2015-1-30 01:22:35 | 显示全部楼层
  1. ;来自黄名儒
  2. ;;除去表一部分
  3. ;;(enth 2 3 '(1 2 3 4 5))
  4. (defun enth (from to lst / I L)
  5.   (setq i -1)
  6.   (foreach x lst
  7.     (setq i (1+ i))
  8.     (cond ((or (< i from) (> i to)) (setq l (cons x l))))
  9.   ) ;_ 结束foreach
  10.   (REVERSE l)
  11. )
发表于 2015-1-30 01:25:46 | 显示全部楼层
  1. ;By 熊掌定制.
  2. ;CAD插件定制 QQ775452144
  3. (defun cx-EListPo(lst e_lst)
  4.         (vl-remove-if '(lambda(x)(member(vl-position x lst)e_lst))lst)
  5. )
发表于 2015-1-30 01:26:48 | 显示全部楼层
(cx-EListPo '(1 2 3 4 5) '(0 3 2))
=> '(2 5)
删除0位 3位 2位的元素.
发表于 2015-1-30 10:06:04 | 显示全部楼层
鱼与熊掌 发表于 2015-1-30 01:25

好强大!又学到一招~
发表于 2015-1-30 11:21:15 | 显示全部楼层
鱼与熊掌 发表于 2015-1-30 01:26
(cx-EListPo '(1 2 3 4 5) '(0 3 2))
=> '(2 5)
删除0位 3位 2位的元素.

(CX-ELISTPO'(1 2 3 1 3 5)'(0 2))
(2 5)
发表于 2015-1-30 11:31:20 | 显示全部楼层
  1. (defun tt(lst en_lst / i a)
  2.   (setq i -1)
  3.   (reverse(repeat(length lst)
  4.     (setq i(1+ i)
  5.           a(if(member i en_lst)a(cons(nth i lst)a)))))
  6.   )

(tt'(1 2 3 1 3 5)'(0 2))
(2 1 3 5)
发表于 2015-1-30 11:37:18 | 显示全部楼层
鱼与熊掌 发表于 2015-1-30 01:22

  1. (defun enth (from to lst / I L)
  2.   (setq i -1)
  3.   (foreach x lst
  4.     (setq i (1+ i)
  5.           l(if(<= from i to)l(cons x l)))
  6.   ) ;_ 结束foreach
  7.   (REVERSE l)
  8. )
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-23 14:18 , Processed in 0.191109 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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