How to turn a list of string into one string in scheme?

user2444642 picture user2444642 · Jun 2, 2013 · Viewed 9.8k times · Source

For example I have (list "a" "1" "b" "2" "c" "3").

Now I want to turn this list into one "a1b2c3".

How do I do that?

Thank you.

Answer

Wes picture Wes · Jun 2, 2013

(apply string-append (list "a" "1" "b" "2" "c" "3")) or (string-append* "" (list "a" "1" "b" "2" "c" "3")) should work. See: http://docs.racket-lang.org/reference/strings.html

If you wanted a procedure to do this you can just write (define (strings->string sts) (apply string-append sts))