/ Published in: Clojure
Taken from here http://groups.google.com/group/clojure/msg/1590311bac972d15, useful if you can not (or do not want to) line-seq file (e.g. when whole file is one big line).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(defn lazy-input "Returns a lazy sequence of characters from an input stream or Reader." [input-stream] (let [step (fn step [] (let [c (.read input-stream)] (when-not (== c -1) (cons (char c) (lazy-seq (step))))))] (lazy-seq (step))))