Wow, that's awesome, thanks for the quick reply.

I found when I opened the stream with (with-open ...) the lazy seq
would throw an exception because the stream is already closed by the
time the repl is trying to print it, so I forced it with a doall:

(with-open [f (open-my-file "foo.exprs")] (doall (read-all f)))

Thanks again Meikel...

Mike

On Jan 14, 7:08 am, Meikel Brandmeyer <m...@kotka.de> wrote:
> Hi,
>
> you can use lazy-seq:
>
> (def eof-marker (Object.))
>
> (defn read-all
>   [stream]
>   (lazy-seq
>     (let [x (read stream false eof-marker)]
>       (when-not (identical? x eof-marker)
>         (cons x (read-all stream))))))
>
> Or go for high-level:
>
> (def eof-marker (Object.))
>
> (defn read-all
>   [stream]
>   (take-while #(not (identical? % eof-marker)) (repeatedly #(read
> stream false eof-marker))))
>
> Sincerely
> Meikel

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to