autolisp列表如(1 2 3 4 5 6 7 8 9 );获得3到6之间的子列表怎么写命令

得到的列表是(3 4 5 6 );去掉第3个列表的程序怎么写,得到的列表(1 2 4 5 6 7 8 9),没有3了;
格式如
(defun c2r (xlist) (cdr xlist) );;;;;;;;;;;;;;第二个元素起的列表
(defun c3r (xlist) (cddr xlist) );;;;;;;;;;;;;第三个元素起的列表
(defun c4r (xlist) (cdddr xlist) );;;;;;;;;;;;第四个元素起的列表
(defun c5r (xlist) (cddddr xlist) );;;;;;;;;;;第五个元素起的列表
(defun c6r (xlist) (cdr (cddddr xlist)) );;;;;第六个元素起的列表
格式如
(defun n1h (xlist) (car xlist) );;;;获得列表第一个元素
(defun n2h (xlist) (cadr xlist) );;;获得列表第二个元素
(defun n3h (xlist) (caddr xlist) );;获得列表第三个元素

(setq a '(1 2 3 4 5 6 7 8 9))
;;;;提取表n至m项无素
;;;用法:(getlst_n->m a 3 6)
;;;返回:表
;;;例:(getlst_n->m a 3 6) 返回(3 4 5 6)
(defun getlst_n->m (lst n m / new_lst)
(repeat (1+ (- m n))
(setq new_lst (cons (nth (1- n) lst) new_lst))
(setq n (1+ n))
)
(reverse new_lst)
)

;;;;删除指定第几项元素
;;;用法:(del_lst-n a 3) 删除表a第3项元素
;;;返回:表
;;;例:(del_lst-n a 3) 返回 (1 2 4 5 6 7 8 9)
(defun del_lst-n (lst n / new_lst tem_lst m )
(setq tem_lst lst m 0)
(repeat (1- n)
(setq new_lst (cons (nth m lst) new_lst))
(setq m (1+ m))
(setq tem_lst (cdr tem_lst))
)
(append (reverse new_lst) (cdr tem_lst))
)
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-08-18
何必那么麻烦,直接的办法:
(vl-remove 3 '(1 2 3 4 5 6 7 8 9))
;返回:(1 2 4 5 6 7 8 9)追问

这个是子程序,以后用来调用的,谢谢你的回答,可能我说的不够清楚

第2个回答  2013-08-18
用循环重组一个表啊,我没有更好的办法,nth只是有点浪费追问

就是要这个表,怎么编?提示一下!谢谢!我不会编!

相似回答