   separated by an optional separator."
   ([coll]
    (loop [sb (StringBuffer.) coll (seq coll)]
-     (if coll
+     (if-not (nil? coll)
        (recur (. sb (append (str (first coll)))) (next coll))
        (.toString sb))))
   ([separator coll]
    (loop [sb (StringBuffer.) coll (seq coll)]
-     (if coll
+     (if-not (nil? coll)
        (do
          (. sb (append (str (first coll))))
          (let [coll (next coll)]

  [s limit]
  (if (or (<= limit 0) (>= limit (+ 2 (count s))))
    (conj (vec (cons "" (map str (seq s)))) "")
    (condp = limit
      1 (vector s)
      2 (vector "" s)
      (let [c (- limit 2)]

(defn- pop-last-while-empty
  [v]
  (loop [v v]
    (if (identical? "" (peek v))
      (recur (pop v))
      v)))

(defn- discard-trailing-if-needed
  [limit v]
  (if (== 0 limit)
    (pop-last-while-empty v)
    v))

