开发者

Spit and Slurp a vector in Clojure

开发者 https://www.devze.com 2023-02-02 20:36 出处:网络
I am trying to spit a vector like [[1 2 3] [4 5 6]] into a file and later slurp it, but when I slurp it I get a string not a vector. Even if I evaluate the string I 开发者_开发问答get, it is still giv

I am trying to spit a vector like [[1 2 3] [4 5 6]] into a file and later slurp it, but when I slurp it I get a string not a vector. Even if I evaluate the string I 开发者_开发问答get, it is still gives a string. I tried to use (vectors slurpt-string) still it give a one element vector containing the string. Any comments?

Thanks in advance.


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]]")

0

精彩评论

暂无评论...
验证码 换一张
取 消