Am 07.12.2008 um 09:55 schrieb rzez...@gmail.com:
> This solution worked for me and you can see my patch at the following
> url.
>
> http://paste.lisp.org/display/71744
This is of course no solution to the problem, but if you don't want
to start patching Clojure you can have a workaround for seqs:
(reduce (fn [x _] (inc x)) 0 the-seq).
> Keep in mind I just whipped this up to test Chouser's idea. I'm
> completely new to the Clojure code base so this is a naive fix at
> best. I noticed that quite a few classes seem to fall under the
> IPersistentCollection umbrella so I'm sure the real patch is bigger
> than this. Also the array only needs to be of size 1, obviously.
I'm not sure, that this is a general problem. Vectors, maps, sets
and lists have all an O(1) count. So I presume the have this stored
in some instance variable somewhere.
For general seqs however, this is not true. Eg. a line seq doesn't
know the number of lines in advance. A seq originating from a
collection however, could provide also an O(1) count.
Or am I mistaken?
Sincerely
Meikel