(setq sysvar-list(list (if (getvar "osmode") "osmode") (if (getvar "3dosmode") "3dosmode") (if (getvar "cmdecho") "cmdecho") (if (getvar "orthomode") "orthomode") (if (getvar "clayer") "clayer")))
For a given acad version , it will return
("osmode" nil "cmdecho" "orthomode" "clayer")
I need it to be as follow
("osmode" "cmdecho" "orthomode" "clayer")
Thanks in advance
Solved! Go to Solution.
Solved by hak_vz. Go to Solution.
(setq sysvar-list (vl-remove-if-not 'getvar '("osmode" "3dosmode" "cmdecho" "orthomode" "clayer")))
@devitg wrote:
Thanks you both for the answer to my original post , it work as spected. But if I want to get rid of a a NIL at any list ? (setq list-w-nil (list 123 nil "qwerty" 678 ))
You're welcome, devitg
Another
(setq list-w-nil (list 123 nil "qwerty" 678 )) (foreach l list-w-nil (if l (setq list-w-no-nil (cons l list-w-no-nil)) ) )
HTH
Henrique
And another few
(defun rem-nil1 ( l ) (if l (if (car l) (cons (car l) (rem-nil1 (cdr l))) (rem-nil1 (cdr l)))) )
(defun rem-nil2 ( l ) (apply 'append (mapcar '(lambda ( x ) (if x (list x))) l)) )
(defun rem-nil3 ( l ) (apply 'append (subst nil '(nil) (mapcar 'list l))) )
And another few
As always, fast reasoning...
Nicely coded, Lee.
Henrique
Thanks Henrique!
hi
thank for your respond
how about removing nil Only from end of list?
for example this is my list:
(12 23 "aa"
15 87 Nil
43 19 "ba"
24 27 "ab"
Nil Nil Nil
Nil Nil Nil)
and i want to remove Nils from end of list.
@ehsan_bahrani wrote:hi
thank for your respond how about removing nil Only from end of list?
for example this is my list:
'(12 23 "aa" 15 87 Nil 43 19 "ba" 24 27 "ab" Nil Nil Nil Nil Nil Nil)and i want to remove Nils from end of list.
(setq a '(12 23 "aa" 15 87 Nil 43 19 "ba" 24 27 "ab" Nil Nil Nil Nil Nil Nil))
(setq a (reverse a))
(while (not (car a)) (setq a (cdr a)))
(setq a (reverse a))
;--> (12 23 "aa" 15 87 nil 43 19 "ba" 24 27 "ab")
Miljenko Hatlak