On Sun, Feb 15, 2009 at 6:44 PM, Rich Hickey <richhic...@gmail.com> wrote: > I realize you are focused on filter, but that point of the fully lazy > branch is full laziness, which would not fall out of what you > describe. lazy-cons requires the lazy sequence function do all the > work that precedes the call to lazy-cons, making functions like drop > and filter not fully lazy.
I was thinking that with an empty sentinel, lazy-cons does not have to do work ahead of time to see whether you're at the end. If you have a lazy-cons, you know you're not empty without evaluating the first or rest, and if you have the empty object, you're empty. So I think you could make lazy-cons fully lazy. I haven't fully thought this through though, so maybe I'm missing something. > Doing so yields a significant (> 60%) speed improvement, without it, > all lazy calls (empty?/first/rest) have a double indirection, and no > way to get rid of it. The 60% speed improvement is compelling, but I was thinking that (especially with an empty sentinel) empty? could be implemented more efficiently than (not (seq coll)), so the empty?/first/rest style wouldn't have such a performance hit. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---