Clojure subvectors are "second class" data structures in terms of operations 
supported on them in several ways, partly because of the O(1) way that they are 
constructed and represented, and/or lack of implementations that work on the 
subvector data structure.

The issue you raise is similar to this one:

    http://dev.clojure.org/jira/browse/CLJ-1082

I made one of the comments there about the possibility in the future of 
implementing subvec as an O(log n) operation rather than O(1), after there is 
an implementation of Reduced Radix Balanced Tree vectors.  If this were done, 
subvectors would become just another kind of vector, and most or all of the 
limitations of operations supported on them would go away.

RRB Tree vectors would also support O(log n) concatenation of two vectors.

Andy

On Dec 27, 2012, at 10:05 AM, Steven Obua wrote:

> I am using Clojure 1.4.0. It seems that reduce-kv does not work together with 
> subvec.
> 
> For example:
> 
> (reduce-kv (fn [v index u] (+ v (* index u))) [10 3 5])
> 
> results in 13, but 
> 
> (reduce-kv (fn [v index u] (+ v (* index u))) 0 (subvec [11 10 3 5] 1 3))
> 
> yields the following exception:
> 
> No implementation of method: :kv-reduce of protocol: 
> #'clojure.core.protocols/IKVReduce found for class: 
> clojure.lang.APersistentVector$SubVector
>   [Thrown class java.lang.IllegalArgumentException]
> 
> -- 
> 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