listvectorclojuresequences

In Clojure, when should I use a vector over a list, and the other way around?


I read that Vectors are not seqs, but Lists are. I'm not sure what the rationale is for using one over the other. It seems that vectors are used the most, but is there a reason for that?


Solution

  • I had a quick discussion with Rich Hickey, and here is the gist of it.

    [12:21] <Raynes>    Vectors aren't seqs, right?
    [12:21] <rhickey>   Raynes: no, but they are sequential
    [12:21] <rhickey>   ,(sequential? [1 2 3])
    [12:21] <clojurebot>    true
    [12:22] <Raynes>    When would you want to use a list over a vector?
    [12:22] <rhickey>   when generating code, when generating back-to-front
    [12:23] <rhickey>   not too often in Clojure