Re: Lazy recursive walk.

2010-01-18 Thread Nicolas Buduroi
On Jan 18, 10:55 pm, Tom Hicks wrote: > Hey, congratulations on finding and fixing the problem! > > And thanks for the great link to the zipper explanationzippers > were > at the top of my list to learn (seriously). Did you catch this other > useful > link (in the comments of the article you p

Re: Lazy recursive walk.

2010-01-18 Thread Tom Hicks
Hey, congratulations on finding and fixing the problem! And thanks for the great link to the zipper explanationzippers were at the top of my list to learn (seriously). Did you catch this other useful link (in the comments of the article you provided)? http://okmij.org/ftp/Computation/Continua

Re: Lazy recursive walk.

2010-01-18 Thread Nicolas Buduroi
I've now changed my test method to this. (def pit (iterate list "bottom!")) (defn get-bottom [p] (loop [p (first p)] (if (seq? p) (recur (first p)) p))) (defn test-walk [walker shallowest deepest] (doseq [depth (range shallowest deepest)] (println (get-bottom (walker #

Re: Lazy recursive walk.

2010-01-18 Thread Nicolas Buduroi
I've found the real problem. The overflow was coming from recursion between pr-on and print-method. It must be that way because it's not really useful to print such deeply nested data structure anyway. On Jan 18, 7:06 pm, Nicolas Buduroi wrote: > On Jan 16, 7:33 pm, Laurent PETIT wrote: > > > Fo

Re: Lazy recursive walk.

2010-01-18 Thread Nicolas Buduroi
On Jan 16, 7:33 pm, Laurent PETIT wrote: > For the non lazy version , maybe using clojure.zip would help not blow > up the stack ? > > (using clojure.zip/zip + a loop with recur on clojure.zip/next) ? I've just tried it and it appears to be equivalent to the lazy walk version, which I think is fu

Re: Lazy recursive walk.

2010-01-17 Thread Nicolas Buduroi
> Sorry, I forgot to ask: how rapid is "rapidly"? Oh, I'd say I misused that word, at least it's way more than I need for what I use this for. I created this post only to see if someone would have an idea for a fully lazy version out of curiosity. From my experiments, the non-recursive version blo

Re: Lazy recursive walk.

2010-01-16 Thread Tom Hicks
On Jan 15, 1:21 pm, Nicolas Buduroi wrote: > Hi, I'm still not familiar with laziness and I'm trying to make a > function recursively walk arbitrary data structures to perform some > action on all strings. > ... > Is there a way too make a fully lazy version of this function? > > - budu I'm tryin

Re: Lazy recursive walk.

2010-01-16 Thread Tom Hicks
On Jan 15, 1:21 pm, Nicolas Buduroi wrote: > Hi, I'm still not familiar with laziness and I'm trying to make a > function recursively walk arbitrary data structures to perform some > action on all strings. The non-lazy version is quite easy to do: > > (use >   'clojure.walk >   'clojure.contrib.st

Re: Lazy recursive walk.

2010-01-16 Thread Tom Hicks
Sorry, I forgot to ask: how rapid is "rapidly"? Can you provide a simple example that rapidly blows the stack so we can experiment with lazy solutions? -tom On Jan 15, 1:21 pm, Nicolas Buduroi wrote: > > But it blow up the stack quite rapidly, ... > ... > - budu -- You received this mes

Re: Lazy recursive walk.

2010-01-16 Thread Tom Hicks
On Jan 15, 1:44 pm, Nicolas Buduroi wrote: > On Jan 15, 3:25 pm, Sean Devlin wrote: > > > Did you try wrapping everything w/ a call to lazy-seq? > > Yes, it doesn't seem change anything. I suspect that just wrapping everything in a call to lazy-seq cannot work in this case. In the implementatio

Re: Lazy recursive walk.

2010-01-16 Thread Laurent PETIT
For the non lazy version , maybe using clojure.zip would help not blow up the stack ? (using clojure.zip/zip + a loop with recur on clojure.zip/next) ? 2010/1/15 Nicolas Buduroi : > Hi, I'm still not familiar with laziness and I'm trying to make a > function recursively walk arbitrary data struct

Re: Lazy recursive walk.

2010-01-15 Thread Nicolas Buduroi
On Jan 15, 3:25 pm, Sean Devlin wrote: > Did you try wrapping everything w/ a call to lazy-seq? Yes, it doesn't seem change anything. -- 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

Re: Lazy recursive walk.

2010-01-15 Thread Sean Devlin
Did you try wrapping everything w/ a call to lazy-seq? On Jan 15, 3:21 pm, Nicolas Buduroi wrote: > Hi, I'm still not familiar with laziness and I'm trying to make a > function recursively walk arbitrary data structures to perform some > action on all strings. The non-lazy version is quite easy t

Lazy recursive walk.

2010-01-15 Thread Nicolas Buduroi
Hi, I'm still not familiar with laziness and I'm trying to make a function recursively walk arbitrary data structures to perform some action on all strings. The non-lazy version is quite easy to do: (use 'clojure.walk 'clojure.contrib.str-utils) (defn recursive-string-walk [f form] (walk #(