I am trying to loop over a list of strings with dolist, and join element with a prefix string, using string-join from subr-x to create new string.
(dolist (p '("a" "b" "c"))
(string-join '(p ".rnc")))
I am getting the error Wrong type argument: sequencep, p. The following code however works.
(dolist (p '("a" "b" "c"))
(print p))
So this seems to be a problem of string-join or equivalently mapconcat within a loop. Any suggestions? Thanks!
It's very important to understand that
'...which means(quote ...)is not a shorthand for making lists.It's a form which causes lisp to return, unevaluated, the object that was created by the lisp reader.
In this instance the lisp reader returns a list containing the symbol
pand a string".rnc"-- and the symbolpis indeed not a sequence (hence your error).Use
(list p ".rnc")to create a list using the evaluated value ofpas a variable.p.s. Be sure to go over the distinct
readandevalphases of lisp execution. Once you understand the distinction,quotewill make much more sense.