Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Tassilo Horn
Alan Malloy writes: > On Aug 26, 12:40 pm, Tassilo Horn wrote: >> Paul  Mooser writes: >> >> Hi Paul, >> >> > If you search for "filter" and "StackOverflowError" in this group, you >> > will find people discussing related issues. >> >> Thanks, I've found some explanation by Meikel Brandmeier wh

Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Alan Malloy
On Aug 26, 12:40 pm, Tassilo Horn wrote: > Paul  Mooser writes: > > Hi Paul, > > > If you search for "filter" and "StackOverflowError" in this group, you > > will find people discussing related issues. > > Thanks, I've found some explanation by Meikel Brandmeier who explains > the layering issue.

Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Tassilo Horn
Paul Mooser writes: Hi Paul, > If you search for "filter" and "StackOverflowError" in this group, you > will find people discussing related issues. Thanks, I've found some explanation by Meikel Brandmeier who explains the layering issue. But do we really have to live with that? I mean, repla

Joy of Clojure lazy quicksort doesn't seem to save comparisons?! (was: StackOverflowError with lazy qsort of The Joy of Clojure)

2011-08-26 Thread Tassilo Horn
Tassilo Horn writes: Now I'm really a bit confused. I've just added atom counters and increased them in the comparison functions in order to check if the lazy variants really test less than the standard sort. > A better solution [that doesn't overrun the stack] seems to be to use > a sequence c

Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Paul Mooser
If you search for "filter" and "StackOverflowError" in this group, you will find people discussing related issues. On Aug 26, 10:30 am, Tassilo Horn wrote: > Do you have a link to the issue?  I've tried searching for "filter" or > "layer" at dev.clojure.org, but I can't find anything... -- You

Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Tassilo Horn
Tassilo Horn writes: >> I've seen people solve these issues by forcing the intermediate seqs, >> but that doesn't work well for a lazy situation such as this. > > Indeed, putting a doall around the filter and remove seems to prevent > the stack overflow. A better solution seems to be to use a se

Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Tassilo Horn
Paul Mooser writes: Hi Paul, > Looking at the stack trace, I suspect this is the old problem of > layering too many filters on top of the same seq. If I understand the > issue correctly, when you have enough layers of filter on top of a > seq, when you finally try to access elements, as it eval

Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Paul Mooser
Looking at the stack trace, I suspect this is the old problem of layering too many filters on top of the same seq. If I understand the issue correctly, when you have enough layers of filter on top of a seq, when you finally try to access elements, as it evaluates each layer, it is going to be makin

StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Tassilo Horn
Hi all, I'm toying around with the lazy, tail-recursive quick-sort implementation Michael Fogus and Chris Houser present in their book The Joy of Clojure: --8<---cut here---start->8--- (in-ns 'user) (defn sort-parts "Lazy, tail-recursive, incremental quickso