【发布时间】:2014-11-21 15:06:16
【问题描述】:
在 Clojure 中将数据结构写入磁盘的最惯用方法是什么,以便我可以使用 edn/read 将其读回?按照Clojure cookbook中的建议,我尝试了以下方法:
(with-open [w (clojure.java.io/writer "data.clj")]
(binding [*out* w]
(pr large-data-structure)))
但是,这只会写入前 100 个项目,然后是“...”。我也尝试了(prn (doall large-data-structure)),得到了相同的结果。
我已经设法通过逐行编写(doseq [i large-data-structure] (pr i)) 来做到这一点,但是我必须在序列的开头和结尾手动添加括号才能获得所需的结果。
【问题讨论】: