Converting a List to a String in Common Lisp

A Google search for “lisp list to string” doesn’t give you anything too helpful, which is kind of weird because it’s really easy.

The CONCATENATE function lets you concatenate any number of items into whatever type of thing you want. Since CONCATENATE is fine with any number of arguments as long as you give it a type, you can pass it just one list, like this:

CL-USER> (concatenate 'string '(#\h #\e #\l #\l #\o))
"hello"

That’s all.

2 Responses to “Converting a List to a String in Common Lisp”

  1. Joe Marshall says:

    (coerce ‘(#\h #\i) ’string)
    => “hi”

  2. Zach Beane says:

    Another option: (map ’string ‘identity ‘(#\w #\o #\o)) => “woo”

Leave a Reply