On Fri, Feb 27, 2009 at 8:33 PM, Jason Wolfe <jawo...@berkeley.edu> wrote: > > If lazy-cons makes your life easier, I think you can still have > something very much like it: > > (defmacro lazy-cons [x s] > `(lazy-seq (cons ~x (lazy-seq ~s))))
As you pointed out, in most contexts, this will double the number of lazy-seq calls, which will really hurt performance. > > If you're interested in perf, you'd just have to write your code a bit > carefully to avoid double lazy-seq'ing the rests: > > (defn map [f coll] > (lazy-seq > (old-map [f coll]))) > > where old-map is the old version of map (modified to cache the call to > "seq"?). Does this make sense? I'm not sure which old-map you mean here. If you mean the old lazy-cons version, using your above macro, this will have too many lazy-seq calls. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---