I am trying to create a list variable that can be set to one list or another depending on a condition. What I have so far is as follows.
(let ((l (if local list1 list2)))
; Append items to the list
)
local
is a parameter that can be set tot
ornil
.list1
andlist2
are list variables.
Then when I later try to access either list1 or list2, I am getting the following error.
Lisp error: (wrong-type-argument sequencep t)
Essentially, what I am trying to do is update either list1 or list2 depending on the value of local. Perhaps this is what is causing my issue.
The following is the shortest code segment that illustrates the problem.
(defvar local-list '())
(defvar global-list '())
(defun add-item-to-list (local item)
(let ((l (if local local-list global-list)))
(add-to-list 'l item)
)
)
(defun print-local-list ()
(mapc (lambda (item) (message item)) local-list)
)
(add-item-to-list t "Blue")
(add-item-to-list t "Greem")
(add-item-to-list t "Red")
(print-local-list)
debug-on-error
tot
and examine the stack.l
and expects a sequence.add-item-to-list
is in the wrong order.local-list
andglobal-list
should be quoted notl
. Therefore I vote to re-open the question.