Search code examples
stringlistelispdelimiter

Numerical lists to field-delimited string with Elisp


I have a requirement where i'd like to generate a comma-separated sequence of numbers with elisp (i want to be able to generate this from within emacs).

Am creating the sequence with

(setq ls (number-sequence 0 5 1))

Now I want to convert this to list of strings so that I may do something like

(s-join "," ls_strings)


Solution

  • The builtin function mapconcat is commonly used for this, eg.

    (mapconcat 'number-to-string (number-sequence 0 5 1) ",")