On Nov 22, 9:48 pm, Rich Hickey <[EMAIL PROTECTED]> wrote:
> map and filter don't modify anything. What does it mean to filter a
> vector?

Yes yes, I know that. Still in English its sometimes easier to be
sloppy and pretend that I modify something even though I get another
vector.

> In any case, the vector itself is immutable, so calling vec on the
> return value of filter is fine.

Well yes its fine but what happens is that filter returns a (lazy) seq
and calling vec on that seq will allocate a new array of the same
length and copy every item over.

> As far as map, if you have a function that will only affect a few of
> the items in the vector, you might want to reduce, making 'changes' as
> you go.

Thanks. That sounds like it would work out nicely. Still in general my
issue seems to be that data strucutres turn into seqs and this can
cause subtle issues as for instance the different behaviour of conj
and a simple rule such as calling vec on the seq seems to be to
costly.

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