function | since v0.0-927 | clojure.string/join | Edit |
(join coll)
(join separator coll)
Returns a string of all elements in coll
, as returned by (seq coll)
,
separated by an optional separator.
Returns a string of all elements in coll, as returned by (seq coll), separated by an optional separator.
(defn join
([coll]
(loop [sb (StringBuffer.) coll (seq coll)]
(if-not (nil? coll)
(recur (. sb (append (str (first coll)))) (next coll))
^string (.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)))
^string (.toString sb)))))