On Nov 23, 1:23 am, Rich Hickey <[EMAIL PROTECTED]> wrote:
> I still don't understand your expectation here. If the filter does any
> filtering, it won't return everything in the vector, so the new result
> will have fewer items. Do you want a vector with fewer items? Then
> you'll have a new vector.

On Nov 23, 7:38 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Sure. But I get a seq and not a vector.  Now don't get me wrong - I
> like the whole sequence library. It's just the performance cost to get
> a vector back. That's why I mean relative to seqs the data structures
> sometimes feel like second class.

I think this discussion is circling around the fact that a Seq is not
a data structure at all; it's a transient view of a collection.  It's
more like an Iterator than a List.  The map function creates a new Seq
that iterates over its argument, and returns a Seq that iterates over
the results of the mapping function.  If you need a vector, you have
to create a new vector.  With immutability, there's no way to avoid
copying, but since the copy will share structure with the original,
the performance penalty should be minimal.  You're still making copies
when you use lists; it's just slightly more convenient to work with
lists because they implement the Seq interface directly.

-Stuart Sierra
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to