• (reverse s)
Returns s with its characters reversed.

2 Examples top

  • user> (reverse "foo")
  • ;; clojure.string/reverse correctly treats UTF-16 surrogate pairs
    ;; as a unit, and does not reverse the 2 Java chars of the pair.  Good!
    user=> (def s "smily \ud83d\ude03.")
    user=> (def x (str/reverse s))
    user=> (map #(format "%04X" (int %)) s)
    ("0073" "006D" "0069" "006C" "0079" "0020" "D83D" "DE03" "002E")
    user=> (map #(format "%04X" (int %)) x)
    ("002E" "D83D" "DE03" "0020" "0079" "006C" "0069" "006D" "0073")
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/string.clj:46 top

(defn ^String reverse
  "Returns s with its characters reversed."
  {:added "1.2"}
  [^CharSequence s]
  (.toString (.reverse (StringBuilder. s))))
Vars in clojure.string/reverse:
Used in 0 other vars

Comments top

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