Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.rrb-vector by

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.

Given: a = (link: a_0, a1, ..., a{n-1}, a{n}, a{n+1}, ..., a{n+k-2}, a{n+k-1}, a{n+k}, ..., a{n+k+m-1})
Goal: (link: a_0, a1, ..., a{n-1}, a{n+k-1}, a{n+k-2}, ..., a{n+1}, a{n}, a{n+k}, ..., a{n+k+m-1})

Possible Clojure implementation of the described operation:

(let [x (subvec a 0 n), y (subvec a n (+ n k)), z (subvec a (+ n k))] (catvec x, (reverse-vec y), z))

1 Answer

0 votes
Reference: https://clojure.atlassian.net/browse/CRRBV-2 (reported by alex+import)