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.
(clojure.string/escape "asdf" {\a \b})
=> "bsdf"
(clojure.string/escape "asdf" {\a "b"})
=> "bsdf"
(clojure.string/escape "asdf" {\a "bb"})
=> "bbsdf"
(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."
{:deprecated "1.2"}
[cmap ^String s]
(let [buffer (StringBuilder. (.length s))]
(dochars [c s]
(if-let [r (cmap c)]
(.append buffer r)
(.append buffer c)))
(.toString buffer)))
Comments top
No comments for escape. Log in to add a comment.