Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (require '[clojure.java.io :as io])
- ;; Will reproduce stack overflow if this file has >= 10000 lines.
- (def input-file "/home/xgp/tmp/def")
- (defn make-reader [input]
- (if (string? input)
- (io/reader input)
- (first input)))
- (defn read-line-or-nil [input]
- (let [reader (make-reader input)]
- (if-let [lines (seq (line-seq reader))]
- [reader lines]
- (do (. reader close)
- nil))))
- (defn read-inputs [inputs]
- (keep read-line-or-nil inputs))
- (let [inputs [input-file]]
- (loop [sq (read-inputs inputs)]
- (when-let [sq (seq sq)]
- (let [[[_ [line]]] sq]
- (println line "recuring")
- (recur (read-inputs sq))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement