;; | --------------------------------------------------------------------------- ;; | LI_SetList ;; | --------------------------------------------------------------------------- ;; | Function : Sets a list to have (contain) exactly a given number of elements ;; | Argument : 'Lst' - List to set ;; | 'len' - Length the list should have ;; | 'Value' - Value the new elements of the list should have ;; | Returns : The new updated list. If original list has lesser number of ;; | elements than the required length number, the updated list will ;; | have the additional items as specified. ;; | If original list has more elements than the required length ;; | number, the list will be truncated to the required length. ;; | Updated : April 23, 2006 ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | --------------------------------------------------------------------------- (defun LI_SetList ( Lst len Value / _Lst diff ) (setq _len (length Lst)) (cond ((> _len len) (setq _Lst (LI_SubList Lst 1 len)) ) ((< _len len) (setq diff (- len _len)) (repeat diff (setq Lst (append Lst (list Value))) ) (setq _Lst Lst) ) ((= _len len) (setq _Lst Lst) ) ) )