Clojure 1.5引入了
如果我想读取前五个对象,可以执行以下操作:
clojure.edn
,其中包括一个需要PushbackReader
的读取函数。如果我想读取前五个对象,可以执行以下操作:
(with-open [infile (java.io.PushbackReader. (clojure.java.io/reader "foo.txt"))]
(binding [*in* infile]
(let [edn-seq (repeatedly clojure.edn/read)]
(dorun (take 5 (map println edn-seq))))))
我该如何打印出所有的对象?考虑到其中一些可能为空,似乎需要检查EOF或类似的东西。我想要一个类似于line-seq
的对象序列。