pr-str

clojure.core

  • (pr-str & xs)
pr to a string, returning it

2 Examples top

  • user=> (def x [1 2 3 4 5])
    #'user/x
    user=> x
    [1 2 3 4 5]
    
    
    ;; Turn that data into a string...
    user=> (pr-str x)
    "[1 2 3 4 5]"
    
    
    ;; ...and turn that string back into data!
    user=> (read-string (pr-str x))
    [1 2 3 4 5]
    
  • ;; you can think of pr-str as the inverse of read-string
    ;; turn string into symbols
    user=> (read-string "(a b foo :bar)")
    (a b foo :bar)
    
    ;;turn symbols into a string
    user=> (pr-str '(a b foo :bar))
    "(a b foo :bar)"
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:4186 top

(defn pr-str
  "pr to a string, returning it"
  {:tag String
   :added "1.0"
   :static true}
  [& xs]
    (with-out-str
     (apply pr xs)))
Vars in clojure.core/pr-str:
Used in 0 other vars

Comments top

No comments for pr-str. Log in to add a comment.