Thanks, Sean. It turns out the exception is being thrown from one of the
Java classes (I should have looked closer). I just assumed that doing the
recursion without loop/recur would always blow the stack eventually. I'll
have to do some research to understand when it does and when it doesn't.
I also pasted in the wrong original function that I was using when I was
getting the exception. The code I pasted does work. The version that's
making the Java code throw the exception has an extra (remove) in it to
remove empty lists. It looks like this:
(defn datamap-seq
"Returns a lazy seq of the records using the given parser and processor"
[parser processor]
(lazy-seq
(when-let [records (next-record parser processor)]
(cons records (remove empty? (datamap-seq parser processor))))))
If I take out that remove and do it elsewhere it works fine. Still puzzling
over that one.
On Friday, September 14, 2012 11:48:23 AM UTC-5, Sean Corfield wrote:
>
> On Fri, Sep 14, 2012 at 8:37 AM, Dave Kincaid
> <[email protected]<javascript:>>
> wrote:
> > I also posted this to StackOverflow, so sorry if you saw it there too.
> If
> > you want some rep points over there you can answer there too
> > (
> http://stackoverflow.com/questions/12427518/clojure-lazy-seq-over-java-iterative-code).
>
>
>
> Looks like there's already a good answer over there.
>
> > Of course when there are a lot of records I end up with a
> > StackOverflowException.
>
> Did you dig into where the StackOverflowException originated from? As
> noted in a comment on SO, the lazy-seq can handle millions of items
> without a problem so the problem isn't inherently with that part of
> your code. Perhaps it's the parser or the processor?
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en