So far it seems that vectors win in Clojure:

(timings 3e5
  (let [v (vector 1 2 3) a (nth v 0) b (nth v 1) c (nth v 2)] (+ a b
c))
  (let [lst (list 1 2 3) a (nth lst 0) b (nth lst 1) c (nth lst 2)] (+
a b c)))

=>
  680.63 ms   83.6%   1.2x  (let [v (vector 1 2 3) a (nth v 0) b (nth
v 1) c (nth v 2)] (+ a b c))
  813.79 ms  100.0%   1.0x  (let [lst (list 1 2 3) a (nth lst 0) b
(nth lst 1) c (nth lst 2)] (+ a b c))

Frantisek

On Jul 8, 7:29 pm, John Harrop <jharrop...@gmail.com> wrote:
> Interesting. How are these timings affected if you add in the time taken to
> pack the list or vector in the first place, though? I have the feeling it
> may be slightly cheaper to unpack a vector, but noticeably cheaper to pack a
> list...
--~--~---------~--~----~------------~-------~--~----~
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
Note that posts from new members are moderated - please be patient with your 
first post.
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