On Tue, Nov 4, 2008 at 8:47 PM, Chanwoo Yoo <[EMAIL PROTECTED]> wrote:
> Thank you for your kind exaplanation. :) To a newbie like me, list and
> vector seemed that they have no significant difference.

No problem, I think everyone runs into these kinds of issues when they
first look at Clojure. However, after spending some time with it, you
start to see how deliberate and consistent these choices were. In this
case, it would be possible to write assoc so that it handled lists,
maybe by having "x" below be the position in the list where to place
the new value, but a) you really aren't "assoc"iating anything,
because lists don't have keys and b) there are different performance
characterstics, assoc on vectors would be O(1) but assoc on lists
would be O(N).

Rich takes great care in trying to guarantee certain performance
characteristics with functions like this, wherever he can. That's one
of the reasons we have vectors in the first place, rather than just
implementing them on top of lists, because vectors and lists have
different performance characteristics and are useful for different
things.

Please someone correct me if I was off on any of the above, but I hope
it's helpful regardless.

Regards,

- J.

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