Add core-pr-str function definition (was missing — only binding existed)
core-pr-str produces Clojure-readable strings: nil→nil, strings→"...", keywords→:kw, booleans→true/false, numbers→string 316 ok, 1 fail (pre-existing, unchanged)
This commit is contained in:
parent
2b6200adad
commit
9ac8f26a70
1 changed files with 17 additions and 0 deletions
|
|
@ -644,6 +644,23 @@
|
||||||
(print "\n")
|
(print "\n")
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
|
(defn core-pr-str [& xs]
|
||||||
|
(def buf @"")
|
||||||
|
(var i 0)
|
||||||
|
(let [n (length xs)]
|
||||||
|
(while (< i n)
|
||||||
|
(def v (xs i))
|
||||||
|
(cond
|
||||||
|
(nil? v) (buffer/push-string buf "nil")
|
||||||
|
(string? v) (do (buffer/push-string buf "\"") (buffer/push-string buf v) (buffer/push-string buf "\""))
|
||||||
|
(keyword? v) (do (buffer/push-string buf ":") (buffer/push-string buf (string v)))
|
||||||
|
(= true v) (buffer/push-string buf "true")
|
||||||
|
(= false v) (buffer/push-string buf "false")
|
||||||
|
(buffer/push-string buf (string v)))
|
||||||
|
(when (< (+ i 1) n) (buffer/push-string buf " "))
|
||||||
|
(++ i)))
|
||||||
|
(string buf))
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Array primitives (needed for persistent data structures)
|
# Array primitives (needed for persistent data structures)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue