1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| ;To convert a list to string, use mapconcat or format. [see Emacs Lisp: Format String]
;mapconcat
;(mapconcat function sequence separator)
;Apply function to each element, and concat the results as strings, with separator between elements.
;; list to string
(string-equal
(mapconcat 'number-to-string '(1 2 3) ",")
"1,2,3")
;; list to string
(string-equal
(mapconcat 'identity '("a" "b" "c") ",")
"a,b,c")
;; vector to string
(string-equal
(mapconcat 'number-to-string [1 2 3] ",")
"1,2,3")
(format "%s" sequence)
Return a string.
;; convert list to string
(format "%s" '(1 "two" 3))
;; "(1 two 3)"
(substring (format "%s" '(1 "two" 3)) 1 -1)
;; "1 two 3"
|