On Fri, Nov 28, 2008 at 3:45 PM, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote: > > Hi, > > On 28 Nov., 14:37, "Michael Wood" <[EMAIL PROTECTED]> wrote: >> I assume (count largecoll) and (empty? largecoll) would be more >> efficient than (seq largecoll)? > > Since empty? is implemented as #(not (seq %)) there is no
OK. > difference for those. count is O(1) for maps, sets, vectors and > lists. I think, that seq is also O(1). It just provides a view > on a collection. Setting up the view can be as easy as setting > a counter to zero (or even just returning the collection as in > case of a list). But there might be pathological examples, > where this is not the case. Perhaps I should have said large-string instead of largecoll. That's really what I was thinking about. I imagine counting characters in a string will be quicker than setting up a bunch of pointers or copying a bunch of characters and then garbage collecting them again. They might both be O(1), but one O(1) is still likely bigger than the other :) -- Michael Wood <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---