;; | --------------------------------------------------------------------------- ;; | LI_RepList ;; | --------------------------------------------------------------------------- ;; | Function : Replaces a member of the list at the specified position ;; | Argument : 'Lst' - The list to operate on. ;; | 'Pos' - Postion in list after which the new element is to be ;; | replaced (starts with 1). ;; | 'Val' - The new value of the list member ;; | Returns : The updated list, if 'pos' is greater than the length of the ;; | list, the function returns nil ;; | Update : October 13, 1998 ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | --------------------------------------------------------------------------- (defun LI_RepList (Lst Pos Val / Lst1 Lst2 cnt len ) (setq cnt 0 len (length Lst) Lst1 '() ) (if (and (> Pos 0) (<= Pos len)) (progn (repeat (1- Pos) (setq Lst1 (cons (nth cnt Lst) Lst1) cnt (1+ cnt) ) ) (setq Lst1 (cons Val Lst1) Lst1 (reverse Lst1) cnt Pos ) (if (> len cnt) (progn (setq Lst2 '()) (repeat (- len cnt) (setq Lst2 (cons (nth cnt Lst) Lst2) cnt (1+ cnt) ) ) (setq Lst2 (reverse Lst2) Lst1 (append Lst1 Lst2) ) )) )) Lst1 )