/ 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).
- (defn lazy-input
- "Returns a lazy sequence of characters from an input stream or Reader."
- (let [step (fn step 
- (let [c (.read input-stream)]
- (when-not (== c -1)
- (cons (char c) (lazy-seq (step))))))]
- (lazy-seq (step))))
You need to login to post a comment.