(join coll) (join separator coll)
Returns a string of all elements in coll, as returned by (seq coll), separated by an optional separator.
user=> (clojure.string/join ", " [1 2 3])
"1, 2, 3"
;; Splits a string on space character and joins
;; the resulting collection with a line feed character
(use '[clojure.string :only (join split)])
user=> (println
(join "\
"
(split "The Quick Brown Fox" #"\\s")))
The
Quick
Brown
Fox
nil
;; Note that empty strings and nils will appear as blank items
;; in the result:
(require '[clojure.string :as string])
(string/join ", " ["spam" nil "eggs" "" "spam"])
;;=> "spam, , eggs, , spam"
;; If you'd like to avoid this, you might do something like this:
(string/join ", " (remove string/blank? ["spam" nil "eggs" "" "spam"]))
;;=> "spam, eggs, spam"