Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of chars to string in Emacs Lisp

I have a list of characters (?h ?e ?l ?l ?o) and i want to convert it to string "hello". Currently i use this structure:

(concat (mapcar (lambda (ch) (char-to-string ch)) s))

Is there a more elegant and idiomatic way to convert list of chars to a string in Elisp?

like image 275
Mirzhan Irkegulov Avatar asked Jan 06 '13 21:01

Mirzhan Irkegulov


2 Answers

Elisp's concat returns a string:

(concat '(?h ?e ?l ?l ?o))

(Found it out from coerce implementation in cl)

like image 111
Anton Kovalenko Avatar answered Sep 25 '22 23:09

Anton Kovalenko


There's also (apply #'string LIST-OF-CHARS).

like image 30
Stefan Avatar answered Sep 22 '22 23:09

Stefan