On Thu, 2012-03-29 at 23:31 -0700, Benjamin Peter wrote:
> the sequence would have been traversed completely by the reduce call
> and therefore clojure could know it's size and provide a constant time
> count.
> 
> Could this be implemented?

Yes.  You could probably implement it yourself, as a wrapper sequence
type, though this wouldn't make all other sequence types automatically
countable.

> Is it?

It won't be, in general, because you would have to "hold onto the head"
until you got to the end, or go through a costly half-broken weak
reference dance.

It is worth considering that even for some uncounted sequences, the cost
of a second traversal for "count" may be less than the bookkeeping cost
of keeping a count as you traverse once.

-- 
Stephen Compall
^aCollection allSatisfy: [:each|aCondition]: less is better

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