;; | --------------------------------------------------------------------------- ;; | LI_AddList ;; | --------------------------------------------------------------------------- ;; | Function : Adds an item to a list at the specified position ;; | Argument : 'Lst' - The list to operate on. ;; | 'Pos' - Postion in list AFTER which the new element ;; | is to added. Starts from 1 ;; | If 'pos' is grteater than the number of elements ;; | in the list, the extra items in the list will be ;; | created as nil elements. ;; | 'Val' - The new value of the list member ;; | Returns : The updated list ;; | Updated : October 13, 1998 ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | --------------------------------------------------------------------------- (defun LI_AddList (Lst Pos Val / Lst1 Lst2 cnt nverts ) (setq cnt 0 Lst1 '() nverts (length Lst) ) (repeat Pos (setq Lst1 (cons (nth cnt Lst) Lst1) cnt (1+ cnt) ) ) (setq Lst1 (cons Val Lst1) Lst1 (reverse Lst1) cnt Pos ) (if (> nverts Pos) (progn (setq Lst2 '()) (repeat (- nverts Pos) (setq Lst2 (cons (nth cnt Lst) Lst2) cnt (1+ cnt) ) ) (setq Lst2 (reverse Lst2) Lst1 (append Lst1 Lst2) ) )) Lst1 )