i have function return list. may return blank list or number list. apply add-to-list return value. possible?
(defun return-list () body....) (setq test (add-to-list (return-list) 1) )
function add-to-list operates on variables, not lists. e.g.:
(defvar test (return-list)) (add-to-list 'test 1) if adding list unconditionally, use macro push operates on places:
(push 1 test) in case, however, can simpler:
(setq test (cons 1 (return-list))) if want add element if not there yet, use macro cl-pushnew operates on places too:
(pushnew 1 test) ;; `test' (1) (pushnew 1 test) ;; `test' still (1)
Comments
Post a Comment