Simple mapping over lists is done with mapcar
. Concatenating strings works in principle with concat
. But, in most cases mapconcat
is better.
(setq list '("Sample Data" "More Fun"))
(setq list (mapcar (lambda (str)
(concat str " is great"))
list))
Example for mapconcat
: Let us assume that you have given a variable tail
with string value "is great"
. The space before is
is missing. mapconcat
inserts the separator between the strings.
(let ((list '("Sample Data" "More Fun"))
(tail "is great"))
(setq list (mapcar (lambda (str)
(mapconcat #'identity (list str tail) " "))
list)))
I also use a let
form here instead of a simple setq
avoiding the polution of the global namespace.