Spit and Slurp Vector in Clojure

I try to splash a vector like [[1 2 3] [4 5 6]] into the file and then slurp it, but when I cheat it, I get a string, not a vector. Even if I evaluate the string that I get, it still gives the string. I tried using (vectors slurpt-string), but it gives one element vector containing a string. Any comments?

Thanks in advance.

+6
serialization clojure
source share
1 answer

clojure.core / read-string

(spit "foo" [[1 2 3] [4 5 6]])

(slurp "foo") ; "[[1 2 3] [4 5 6]]"

(read-string *1) ; [[1 2 3] [4 5 6]]

(type *1) ; clojure.lang.PersistentVector


(read-string "[[1 2 3] [4 5 6]]")

+6
source share

All Articles