Here's a somewhat old but still generally useful article on how Clojure
vectors are implemented:
http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/


Vectors are optimized for random access, whereas lists are optimized for
going through from the beginning to the end, which is exactly what the last
function does.

On Thu, Jun 28, 2012 at 7:36 PM, David Nolen <dnolen.li...@gmail.com> wrote:

> On Thu, Jun 28, 2012 at 7:32 PM, Warren Lynn <wrn.l...@gmail.com> wrote:
>
>> This is an off-shoot subject from my last post "General subsequence
>> function".
>>
>> I found people had similar questions before (one year ago):
>>
>> http://groups.google.com/group/clojure/browse_thread/thread/712711f049507c63/aea7cf438aa22922
>>
>> As of Clojure 1.4, seems nothing changed, as "source" show here:
>>
>> user> (source last)
>> (def
>>  ^{:arglists '([coll])
>>    :doc "Return the last item in coll, in linear time"
>>    :added "1.0"
>>    :static true}
>>  last (fn ^:static last [s]
>>         (if (next s)
>>           (recur (next s))
>>           (first s))))
>>
>> Any reason for that? Thanks.
>
>
> Don't hold your breath. Assume that the language was designed after much
> consideration. last is a sequence operation, not a collection operation. If
> the distinction doesn't make sense, I suggest you explore the design
> decision by writing some non-trivial Clojure code so you can arrive at your
> own satisfying answer why this was done. Otherwise you'll just listen to
> people repeat the same answer without hearing what is being said.
>
> David
>
> --
> 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
>

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