;;除去表一部分
;;(PartListRemove 2 3 '(1 2 3 4 5))
(defun PartListRemove (from to lst / I L)
(setq i -1)
(foreach x lst
(setq i (1+ i))
(cond ((or (< i from) (> i to)) (setq l (cons x l))))
)
(REVERSE l)
)
;;取表一部分
;;(PartList1 2 3 '(1 2 3 4 5))=>(3 4)
(defun PartList1 (from to lst / I L)
(setq i -1)
(foreach x lst
(setq i (1+ i))
(cond ((and (>= i from) (<= i to)) (setq l (cons x l))))
)
(REVERSE l)
)
;;取表一部分
;;(PartList2 2 3 '(1 2 3 4 5))=(3 4)
(defun PartList2 (from to lst / i L)
(setq i -1)
(mapcar '(lambda (x)
(setq i (1+ i))
(cond ((and (>= i from) (<= i to)) (setq l (cons x l))))
)
lst
)
(REVERSE l)
)
;;取表一部分
;;(PartList3 2 3 '(1 2 3 4 5))=(3 4)
(defun PartList3 (from to lst / I L X)
(setq i -1)
(while (and (setq x (car lst))
(setq lst (cdr lst))
(< i to)
)
(setq i (1+ i))
(cond((>= i from)(setq l (cons x l))))
)
(REVERSE l)
)
;;估计这个快些,纯属猜测
;;取表一部分
;;(PartList4 2 3 '(1 2 3 4 5))=(3 4)
(defun PartList4 (from to lst / L X)
(repeat from (setq lst (cdr lst)))
(repeat (1+ (- to from)) (setq l (cons (car lst) l)) (setq lst (cdr lst)))
(REVERSE l)
)