<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions in core.rrb-vector</title>
<link>https://ask.clojure.org/index.php/questions/contrib-libs/core-rrb-vector</link>
<description></description>
<item>
<title>rrb-vector Unhandled java.lang.ArrayIndexOutOfBoundsException</title>
<link>https://ask.clojure.org/index.php/9815/vector-unhandled-java-lang-arrayindexoutofboundsexception</link>
<description>&lt;p&gt;I faced this error during I'm playing with aoc2018 d9. It seems this error pops up when the vector has items around over 2M.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Execution error (ArrayIndexOutOfBoundsException) at clojure.core.rrb-vector.rrbt/slice-left$fn (rrbt.clj:393).
Index 33 out of bounds for length 33

      rrbt.clj:  393  clojure.core.rrb-vector.rrbt/slice-left/fn
      rrbt.clj:  392  clojure.core.rrb-vector.rrbt/slice-left
      rrbt.clj:  375  clojure.core.rrb-vector.rrbt/slice-left
      rrbt.clj: 1098  clojure.core.rrb-vector.rrbt.Vector/slicev
rrb_vector.clj:   83  clojure.core.rrb-vector/subvec
rrb_vector.clj:   73  clojure.core.rrb-vector/subvec
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I can't find the issue page in github, so I'd like to leave a question here to get a help.&lt;/p&gt;
</description>
<category>core.rrb-vector</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9815/vector-unhandled-java-lang-arrayindexoutofboundsexception</guid>
<pubDate>Tue, 17 Nov 2020 02:02:59 +0000</pubDate>
</item>
<item>
<title>reduce-kv throws IndexOutOfBoundsException on empty rrb-vector</title>
<link>https://ask.clojure.org/index.php/9616/reduce-throws-indexoutofboundsexception-empty-rrb-vector</link>
<description>&lt;p&gt;expected:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(reduce-kv vector nil [])
=&amp;gt; nil
(reduce-kv vector nil [1])
=&amp;gt; [nil 0 1]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;actual in CLJS:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(reduce-kv vector nil (clojure.core.rrb-vector/vec []))
Error: No item 0 in vector of length 0
    at Object.cljs$core$vector_index_out_of_bounds [as vector_index_out_of_bounds] (http://localhost:8080/cljs-runtime/cljs.core.js:19788:8)
    at Object.clojure$core$rrb_vector$rrbt$IVecImpl$_array_for$arity$2 (http://localhost:8080/cljs-runtime/clojure.core.rrb_vector.rrbt.js:1028:18)
    at Object.cljs$core$IKVReduce$_kv_reduce$arity$3 (http://localhost:8080/cljs-runtime/clojure.core.rrb_vector.rrbt.js:613:21)
    at Object.cljs$core$_kv_reduce [as _kv_reduce] (http://localhost:8080/cljs-runtime/cljs.core.js:2359:13)
(reduce-kv vector nil (clojure.core.rrb-vector/vec [1]))
=&amp;gt; [nil 0 1]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;actual in CLJ:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(reduce-kv vector nil (clojure.core.rrb-vector/vec [])) 
Execution error (IndexOutOfBoundsException) at clojure.core.rrb_vector.rrbt.Vector/arrayFor (rrbt.clj:806).
(reduce-kv vector nil (clojure.core.rrb-vector/vec [1])) 
=&amp;gt; [nil 0 1]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;*&quot;vector nil&quot; part is not important here, it is just to justify calling reduce-kv.&lt;/p&gt;
&lt;p&gt;Friday night, forgot to add any versions info:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; :deps  {org.clojure/clojure              {:mvn/version &quot;1.10.1&quot;}
         org.clojure/clojurescript        {:mvn/version &quot;1.10.597&quot;}
         org.clojure/core.rrb-vector      {:mvn/version &quot;0.1.1&quot;}
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>core.rrb-vector</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9616/reduce-throws-indexoutofboundsexception-empty-rrb-vector</guid>
<pubDate>Fri, 18 Sep 2020 13:14:40 +0000</pubDate>
</item>
<item>
<title>Probably a core.rrb-vector bug, exercised via fipp library</title>
<link>https://ask.clojure.org/index.php/6865/probably-a-core-rrb-vector-bug-exercised-via-fipp-library</link>
<description>&lt;p&gt;See the description of the test case involved on this Github issue: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/brandonbloom/fipp/issues/53&quot;&gt;https://github.com/brandonbloom/fipp/issues/53&lt;/a&gt;&lt;/p&gt;
</description>
<category>core.rrb-vector</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/6865/probably-a-core-rrb-vector-bug-exercised-via-fipp-library</guid>
<pubDate>Fri, 02 Nov 2018 17:11:14 +0000</pubDate>
</item>
<item>
<title>core.rrb-vector fails on JDK 11 EA builds</title>
<link>https://ask.clojure.org/index.php/6866/core-rrb-vector-fails-on-jdk-11-ea-builds</link>
<description>&lt;p&gt;I tried to test boot on JDK 11 EA builds and there seems to be fipp somewhere in the dependency chain that has core.rrb-vector 0.0.11 as dependency. It fails with the below error : &lt;/p&gt;
&lt;pre&gt;&lt;code&gt; java.lang.IllegalArgumentException: Must hint overloaded method: toArray
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;clojure.lang.Compiler$CompilerException: java.lang.IllegalArgumentException: Must hint overloaded method: toArray, compiling:(clojure/core/rrb_vector/rrbt.clj:282:1)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;         clojure.lang.ExceptionInfo: java.lang.IllegalArgumentException: Must hint overloaded method: toArray, compiling:(clojure/core/rrb_vector/rrbt.clj:282:1)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Reference Travis build : &lt;a rel=&quot;nofollow&quot; href=&quot;https://travis-ci.org/tirkarthi/boot/jobs/398611988#L803&quot;&gt;https://travis-ci.org/tirkarthi/boot/jobs/398611988#L803&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This was passing a few days back but fails as of now. Feel free to close this if it's fixed in master and it's not released yet. &lt;/p&gt;
&lt;p&gt;Successful build : &lt;a rel=&quot;nofollow&quot; href=&quot;https://travis-ci.org/tirkarthi/boot/jobs/398610834&quot;&gt;https://travis-ci.org/tirkarthi/boot/jobs/398610834&lt;/a&gt;&lt;/p&gt;
</description>
<category>core.rrb-vector</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/6866/core-rrb-vector-fails-on-jdk-11-ea-builds</guid>
<pubDate>Thu, 05 Jul 2018 17:39:53 +0000</pubDate>
</item>
<item>
<title>StackOverflowError when building rrb-vector by concatenation at the beginning</title>
<link>https://ask.clojure.org/index.php/6864/stackoverflowerror-building-vector-concatenation-beginning</link>
<description>I am trying to build rrb-vectors by concatenating singleton vectors at the beginning. I am doing to deliberatelly create relaxed structures, as part of a research project I am conducting on RRB-Trees. &amp;nbsp;However it seems that this causes a stack overflow (I guess, due to some bug in the RRB-Vector structure?):&lt;br /&gt;
&lt;br /&gt;
(def benchmark-size 100000)&lt;br /&gt;
&lt;br /&gt;
(defn vector-push-f [v]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(loop [v v&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i 0]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(if (&amp;lt; i benchmark-size)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(recur (fv/catvec (fv/vector i) v)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(inc i))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;v)))&lt;br /&gt;
&lt;br /&gt;
(def benchmark-rrb-vector-f (vector-push-f (fv/vector)))&lt;br /&gt;
</description>
<category>core.rrb-vector</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/6864/stackoverflowerror-building-vector-concatenation-beginning</guid>
<pubDate>Sun, 19 Feb 2017 23:18:11 +0000</pubDate>
</item>
<item>
<title>Support bootstrapped ClojureScript</title>
<link>https://ask.clojure.org/index.php/6868/support-bootstrapped-clojurescript</link>
<description>&lt;p&gt;Revise code to support bootstrapped ClojureScript.&lt;/p&gt;
&lt;p&gt;(This can be done with a few minor changes to the {{clojure.core.rrb-vector.macros}} namespace.)&lt;/p&gt;
</description>
<category>core.rrb-vector</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/6868/support-bootstrapped-clojurescript</guid>
<pubDate>Mon, 23 Jan 2017 16:38:29 +0000</pubDate>
</item>
<item>
<title>nth fails with ArrayIndexOutOfBoundsException 33  clojure.core.rrb-vector.rrbt.Vector/fn--19277 (rrbt.clj:373)</title>
<link>https://ask.clojure.org/index.php/6863/fails-arrayindexoutofboundsexception-clojure-vector-vector</link>
<description>&lt;p&gt;Was playing with advent of code and puzzle 19 second part.&lt;/p&gt;
&lt;p&gt;I have a program that mostly does catvec + subvec at &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/mattiasw2/adventofcode1/blob/master/src/adventofcode1/nineteen_b.clj&quot;&gt;https://github.com/mattiasw2/adventofcode1/blob/master/src/adventofcode1/nineteen_b.clj&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The smallest sample that fails with &lt;/p&gt;
&lt;p&gt;ArrayIndexOutOfBoundsException 33  clojure.core.rrb-vector.rrbt.Vector/fn--19277 (rrbt.clj:373)&lt;/p&gt;
&lt;p&gt;is &lt;/p&gt;
&lt;p&gt;(puzzle-b 978)&lt;/p&gt;
&lt;p&gt;(I was using (stest/check `puzzle-b) )&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;I reimplemented the program using plain vectors, and everything works fine (except that I haven't been able to run the big sample)&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/mattiasw2/adventofcode1/blob/master/src/adventofcode1/nineteen_c.clj&quot;&gt;https://github.com/mattiasw2/adventofcode1/blob/master/src/adventofcode1/nineteen_c.clj&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;which works fine.&lt;/p&gt;
</description>
<category>core.rrb-vector</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/6863/fails-arrayindexoutofboundsexception-clojure-vector-vector</guid>
<pubDate>Tue, 20 Dec 2016 09:00:35 +0000</pubDate>
</item>
<item>
<title>Throws ClassCastException on assoc</title>
<link>https://ask.clojure.org/index.php/6862/throws-classcastexception-on-assoc</link>
<description>&lt;br /&gt;
(let [coll (into (fv/vector-of :byte) (repeat (* 32 n) 0)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(assoc coll i 1))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
throws ClassCastException [B cannot be cast to [Ljava.lang.Object; &amp;nbsp;clojure.core.rrb-vector.nodes/reify--1261 (nodes.clj:69)&lt;br /&gt;
&lt;br /&gt;
for every i &amp;lt; n * 32 - 32.&lt;br /&gt;
&lt;br /&gt;
So you can assoc to elements in the last internal primitive array, and even extend it to create the next internal primitive array.&lt;br /&gt;
But you can't assoc to elements in any previous internal primitive array.&lt;br /&gt;
&lt;br /&gt;
I wonder why nobody discovered this bug before...</description>
<category>core.rrb-vector</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/6862/throws-classcastexception-on-assoc</guid>
<pubDate>Sat, 01 Oct 2016 22:22:14 +0000</pubDate>
</item>
<item>
<title>ClassCastException: clojure.lang.PersistentVector$Node cannot be cast to [I</title>
<link>https://ask.clojure.org/index.php/6869/classcastexception-clojure-persistentvectornode-cannot</link>
<description>I'm seeing some strange behaviour which I've been unable to find a small failing case for. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(defn quicksort [v]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(if (&amp;lt;= (count v) 1)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;v&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(let [[x &amp;amp; xs] v]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(rrb/catvec (quicksort (filterv #(&amp;lt;= % x) xs)) &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[x]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(quicksort (filterv #(&amp;gt; % x) xs))))))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can check this implementation with test.check&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(defn ascending? [coll]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(every? (fn [[a b]] (&amp;lt;= a b))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(partition 2 1 coll)))&lt;br /&gt;
&lt;br /&gt;
(def property&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(prop/for-all [v (gen/vector gen/int)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(let [s (quicksort v)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(and (= (count v) (count s))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(ascending? s)))))&lt;br /&gt;
&lt;br /&gt;
(tc/quick-check 10000 property)&lt;br /&gt;
&lt;br /&gt;
;; =&amp;gt; {:result true, :num-tests 10000, :seed 1440948212354}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(I've bumped the number of checks to 1e6 but test.check was not able to find a failing case)&lt;br /&gt;
&lt;br /&gt;
Still, for some reason I get a &amp;quot;ClassCastException: clojure.lang.PersistentVector$Node cannot be cast to [I&amp;quot; for the attached 1193 element vector.&lt;br /&gt;
&lt;br /&gt;
{}&lt;br /&gt;
(quicksort (read-string (slurp &amp;quot;failing-1193.edn&amp;quot;)))&lt;br /&gt;
{}</description>
<category>core.rrb-vector</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/6869/classcastexception-clojure-persistentvectornode-cannot</guid>
<pubDate>Sun, 30 Aug 2015 16:34:50 +0000</pubDate>
</item>
<item>
<title>Issue with Clojure 1.8.0-alpha2 Tuples</title>
<link>https://ask.clojure.org/index.php/6859/issue-with-clojure-1-8-0-alpha2-tuples</link>
<description>&lt;p&gt;When trying our core.rrb-vector with the latest Clojure 1.8.0-alpha2 I see the following error:&lt;/p&gt;
&lt;p&gt;Exception in thread &quot;main&quot; java.lang.IllegalArgumentException: No implementation of method: :slicev of protocol: #'clojure.core.rrb-vector.protocols/PSliceableVector found for class: clojure.lang.Tuple$T0, compiling:(mikera/timeline/examples.clj:12:1)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;at clojure.lang.Compiler.load(Compiler.java:7307)
at clojure.lang.RT.loadResourceScript(RT.java:372)
at clojure.lang.RT.loadResourceScript(RT.java:363)
at clojure.lang.RT.load(RT.java:453)
at clojure.lang.RT.load(RT.java:419)
at clojure.core$load$fn__5448.invoke(core.clj:5866)
at clojure.core$load.doInvoke(core.clj:5865)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5671)
at clojure.core$load_lib$fn__5397.invoke(core.clj:5711)
at clojure.core$load_lib.doInvoke(core.clj:5710)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:632)
at clojure.core$load_libs.doInvoke(core.clj:5749)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:632)
at clojure.core$require.doInvoke(core.clj:5832)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at com.theoryinpractise.clojure.testrunner$eval41$iter__42__46$fn__47$fn__48.invoke(run-test181131806783576232.clj:22)
at com.theoryinpractise.clojure.testrunner$eval41$iter__42__46$fn__47.invoke(run-test181131806783576232.clj:21)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.RT.seq(RT.java:514)
at clojure.core$seq__4128.invoke(core.clj:137)
at clojure.core$dorun.invoke(core.clj:3009)
at com.theoryinpractise.clojure.testrunner$eval41.invoke(run-test181131806783576232.clj:21)
at clojure.lang.Compiler.eval(Compiler.java:6850)
at clojure.lang.Compiler.load(Compiler.java:7295)
at clojure.lang.Compiler.loadFile(Compiler.java:7233)
at clojure.main$load_script.invoke(main.clj:275)
at clojure.main$script_opt.invoke(main.clj:337)
at clojure.main$main.doInvoke(main.clj:421)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Caused by: java.lang.IllegalArgumentException: No implementation of method: :slicev of protocol: #'clojure.core.rrb-vector.protocols/PSliceableVector found for class: clojure.lang.Tuple$T0&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:556)
at clojure.core.rrb_vector.protocols$eval965$fn__966$G__956__975.invoke(protocols.clj:6)
at clojure.core.rrb_vector$subvec.invoke(rrb_vector.clj:71)
at mikera.timeline.impl.Timeline.add_event(impl.clj:82)
at mikera.timeline$log.invoke(timeline.clj:64)
at mikera.timeline$log.invoke(timeline.clj:61)
at clojure.lang.Atom.swap(Atom.java:51)
at clojure.core$swap_BANG_.invoke(core.clj:2239)
at mikera.timeline.examples$eval1620.invoke(examples.clj:15)
at clojure.lang.Compiler.eval(Compiler.java:6850)
at clojure.lang.Compiler.load(Compiler.java:7295)
... 36 more
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I believe the cause of this is the new Tuple types. core-rrb-vector should ideally be able to handle this like any other IPersistentVector instance, but it does not currently seem to be able to do so.&lt;/p&gt;
</description>
<category>core.rrb-vector</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/6859/issue-with-clojure-1-8-0-alpha2-tuples</guid>
<pubDate>Wed, 29 Jul 2015 11:06:15 +0000</pubDate>
</item>
<item>
<title>Calling empty in CLJS results in a PersistentVector</title>
<link>https://ask.clojure.org/index.php/6867/calling-empty-in-cljs-results-in-a-persistentvector</link>
<description>&lt;p&gt;I discovered that (pop some-rrb-vec) where some-rrb-vec is of length 1 returns a PersistentVector rather than a clojure.core.rrbt.Vector in ClojureScript.&lt;/p&gt;
&lt;p&gt;This isn't true for the Clojure side, so I assume it's a problem. Patch attached with tests.&lt;/p&gt;
</description>
<category>core.rrb-vector</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/6867/calling-empty-in-cljs-results-in-a-persistentvector</guid>
<pubDate>Wed, 01 Jul 2015 10:18:53 +0000</pubDate>
</item>
<item>
<title>Repeated subvec and catvec fails</title>
<link>https://ask.clojure.org/index.php/6861/repeated-subvec-and-catvec-fails</link>
<description>&lt;p&gt;The attached patch contains a test which fails for both the Clojure and ClojureScript implementations. It simply repeatedly calls subvec and catvec to assemble an interleaved vector. The patch attached contains fixes for Clojure &lt;strong&gt;only&lt;/strong&gt;. I will investigate the fixes for CLJS, but thought it best to raise an issue with my findings so far.&lt;/p&gt;
&lt;p&gt;2371 is the minimum length that exhibits the behaviour (triggers an ArrayIndexOutOfBoundsException).&lt;/p&gt;
</description>
<category>core.rrb-vector</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/6861/repeated-subvec-and-catvec-fails</guid>
<pubDate>Tue, 17 Mar 2015 12:32:17 +0000</pubDate>
</item>
<item>
<title>Efficient reverse resulting in reversed rrb-vector</title>
<link>https://ask.clojure.org/index.php/6860/efficient-reverse-resulting-in-reversed-rrb-vector</link>
<description>&lt;p&gt;Is it possible to implement an efficient reverse on a rrb-vector resulting in an rrb-vector? This would be pretty useful in scenarios like the 2-opt neighborhood for local search for the Traveling Salesman Problem. The complete operation is as follows.&lt;/p&gt;
&lt;p&gt;Given: a = (link: a_0, a&lt;em&gt;1, ..., a&lt;/em&gt;{n-1}, a&lt;em&gt;{n}, a&lt;/em&gt;{n+1}, ..., a&lt;em&gt;{n+k-2}, a&lt;/em&gt;{n+k-1}, a&lt;em&gt;{n+k}, ..., a&lt;/em&gt;{n+k+m-1})&lt;br&gt;
Goal:  (link: a_0, a&lt;em&gt;1, ..., a&lt;/em&gt;{n-1}, a&lt;em&gt;{n+k-1}, a&lt;/em&gt;{n+k-2}, ..., a&lt;em&gt;{n+1}, a&lt;/em&gt;{n}, a&lt;em&gt;{n+k}, ..., a&lt;/em&gt;{n+k+m-1})&lt;/p&gt;
&lt;p&gt;Possible Clojure implementation of the described operation:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;(let [x (subvec a 0 n), y (subvec a n (+ n k)), z (subvec a (+ n k))]
 (catvec x, (reverse-vec y), z))&lt;/code&gt;&lt;/p&gt;
</description>
<category>core.rrb-vector</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/6860/efficient-reverse-resulting-in-reversed-rrb-vector</guid>
<pubDate>Fri, 20 Dec 2013 09:21:09 +0000</pubDate>
</item>
</channel>
</rss>