The following code appears to force line-seq
to read 4 lines from file
. Is this some kind of buffering mechanism? Do I need to use lazy-cat
here? If so, how can I apply
a macro to a sequence as if it were variadic arguments?
(defn char-seq [rdr]
(let [coll (line-seq rdr)]
(apply concat (map (fn [x] (println \,) x) coll))))
(def tmp (char-seq (clojure.contrib.io/reader file)))
;,
;,
;,
;,
#'user/tmp
Part of what you're seeing is due to
apply
, since it will need to realize as many args as needed by the function definition. E.g.: