• (escape s cmap)
Returns a new String by applying cmap (a function or a map) to each
character in s. If cmap returns nil, the original character is
added to the output unchanged.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/str_utils2.clj:93 top

(defn ^String escape
  "Returns a new String by applying cmap (a function or a map) to each
   character in s.  If cmap returns nil, the original character is
   added to the output unchanged."
  [^String s cmap]
  (let [buffer (StringBuilder. (.length s))]
    (dochars [c s]
      (if-let [r (cmap c)]
        (.append buffer r)
        (.append buffer c)))
    (.toString buffer)))
Vars in clojure.contrib.str-utils2/escape: defn if-let let
Used in 0 other vars

Comments top

No comments for escape. Log in to add a comment.