1.2.0 permalink Arrow_down_16x16
  • (escape cmap s)
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.

1 Example top

  • (clojure.string/escape "asdf" {\a \b}) 
    => "bsdf"
    (clojure.string/escape "asdf" {\a "b"}) 
    => "bsdf"
    (clojure.string/escape "asdf" {\a "bb"}) 
    => "bbsdf"
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/string.clj:91 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."
   {: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)))
Vars in clojure.contrib.string/escape: defn if-let let
Used in 0 other vars

Comments top

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