(join coll)
(join separator coll)
Returns a string of all elements in coll, as returned by (seq coll),
separated by an optional separator.
Source
(defn
join
"Returns a string of all elements in coll, as returned by (seq coll),\n separated by an optional separator."
([coll]
(loop
[sb (StringBuffer.) coll (seq coll)]
(if-not
(nil? coll)
(recur (. sb (append (str (first coll)))) (next coll))
(.toString sb))))
([separator coll]
(loop
[sb (StringBuffer.) coll (seq coll)]
(if-not
(nil? coll)
(do
(. sb (append (str (first coll))))
(let
[coll (next coll)]
(when-not (nil? coll) (. sb (append separator)))
(recur sb coll)))
(.toString sb)))))