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 making a call for each layer of filter. With enough layers, you'll blow your stack.
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. On Aug 26, 7:42 am, Tassilo Horn <tass...@member.fsf.org> wrote: > 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 quicksort. Works against > and creates partitions based on the pivot, defined as 'work'." > [work] > (lazy-seq > (loop [[part & parts] work] > (if-let [[pivot & xs] (seq part)] > (let [smaller? #(< % pivot)] > (recur (list* > (filter smaller? xs) > pivot > (remove smaller? xs) > parts))) > (when-let [[x & parts] parts] > (cons x (sort-parts parts))))))) > > (defn qsort [xs] > (sort-parts (list xs))) -- 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