Re: reduce-kv incompatible with subvec

2012-12-29 Thread Andy Fingerhut
I haven't taken the time to check whether that is correct or not, but the answer that is most likely the truth is "no one has yet had the time or interest to add such a thing yet". You are welcome to create a ticket describing the problem, and attach a patch to it that fixes the issue, and see

Re: reduce-kv incompatible with subvec

2012-12-28 Thread Alan Busby
Just curious why something like the following wouldn't be part of subvector? public Object kvreduce(IFn f, Object init){ for(int i=0;i<(end - start);i++){ init = f.invoke(init,i,v.nth(start+i)); return init; } On Fri, Dec 28, 2012 at 11:23 PM, Andy Fingerhut wrote: > I am not

Re: reduce-kv incompatible with subvec

2012-12-28 Thread Andy Fingerhut
I am not saying that one would *have* to give up O(1) subvec in order to support other operations. I am guessing, without having done a thorough analysis, that an O(log n) subvec based on RRB Trees would make most/all operations on subvec's just fall out fairly naturally, rather than having to

Re: reduce-kv incompatible with subvec

2012-12-27 Thread Alan Busby
I'm confused why we'd need to give up O(1) just to support something like reduce-kv on subvectors. Isn't the implementation of subvector just a wrapper around the original vector along with a start and end value? Current source here; https://github.com/clojure/clojure/blob/master/src/jvm/clojure/l

Re: reduce-kv incompatible with subvec

2012-12-27 Thread Steven Obua
Thanks a lot for this comment. It is probably a good idea to flag "subvec" in the docs as dangerous operation that does not really return a full vector. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goo

Re: reduce-kv incompatible with subvec

2012-12-27 Thread Andy Fingerhut
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 t

reduce-kv incompatible with subvec

2012-12-27 Thread Steven Obua
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 implemen