Michal

The last, elegant one works -- marvellous!

Thanks a lot.
Tim

On Jan 28, 1:05 pm, Michał Marczyk <michal.marc...@gmail.com> wrote:
> Ouch, sorry, this won't work with recur... Use an explicit call instead:
>
> (defn multi-read-lines [sources]
>   (when-let [source (first sources)]
>    (lazy-cat (read-lines source) (multi-read-lines (rest sources)))))
>
> I guess this would overflow the stack with a huge number of sources, though.
>
> A second solution which should hopefully be fully lazy (and seems more
> elegant anyway):
>
> (defn multi-read-lines [sources]
>   (reduce (fn [acc s]
>                   (lazy-cat acc (read-lines s)))
>                 nil
>                 sources))
>
> Sincerely,
> Michal

-- 
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