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.
(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)))
Comments top
No comments for escape. Log in to add a comment.