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 <nbudu...@gmail.com>: > 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 #(if (string? %) (f %) (recursive-string-walk f %)) > identity form)) > > But it blow up the stack quite rapidly, I've tried to inject some > laziness inside, but only came up with a slight improvement. It can > take forms that are a little more than two time as deep. > > (defn recursive-string-walk [f form] > (walk #(cond > (string? %) (f %) > (seq? %) (lazy-seq (recursive-string-walk f %)) > :default (recursive-string-walk f %)) > identity form)) > > Is there a way too make a fully lazy version of this function? > > Thanks > > - budu > > -- > 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 >
-- 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