I'm no expert, but I think this explain some:

Clojure's conj function is like Lisp's cons, but "does the right
thing", depending on the data type.  It is fast to add something to
the front of the list, and slower to add something to the end.
Vectors are the opposite, you can add to the end fast, slower to add
to the front.  This isn't specific to Clojure, it's just the way those
data structures work in any language.  So conj adds the item to the
front if it is conjing on a list, to the end if is conjing on a
vector.  This is part of how clojure provides a unified method of
handling different type of data structures, which are collectively
called sequences in Clojure.

Excerpted from here:

http://groups.google.com/group/novalanguages/browse_thread/thread/bcb78a59382227e0

It's also worth noting that lists are the canonical datatype in Lisp,
so they're probably kept around for that reason as well.

Travis

Clojure's conj function is like Lisp's cons, but "does the right
thing", depending on
the data type.  It is fast to add something to the front of the list,
and slower to add something to the end.  Vectors are the opposite, you
can add to the end fast, slower to add to the front.  This isn't
specific to Clojure, it's just the way those data structures work in
any language.  So conj adds the item to the front if it is conjing on
a list, to the end if is conjing on a vector.  This is part of how
clojure provides a unified method of handling different type of data
structures, which are collectively called sequences in Clojure.

On May 15, 3:36 pm, Vagif Verdi <vagif.ve...@gmail.com> wrote:
> What are the use case scenarios where one is preferable to the other
> in clojure ?
>
> It looks to me like vectors almost completely overtake lists for all
> purposes.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to