I'm seeing some strange behaviour which I've been unable to find a small failing case for.
(defn quicksort [v]
(if (<= (count v) 1)
v
(let [[x & xs] v]
(rrb/catvec (quicksort (filterv #(<= % x) xs))
[x]
(quicksort (filterv #(> % x) xs))))))
We can check this implementation with test.check
(defn ascending? [coll]
(every? (fn [[a b]] (<= a b))
(partition 2 1 coll)))
(def property
(prop/for-all [v (gen/vector gen/int)]
(let [s (quicksort v)]
(and (= (count v) (count s))
(ascending? s)))))
(tc/quick-check 10000 property)
;; => {:result true, :num-tests 10000, :seed 1440948212354}
(I've bumped the number of checks to 1e6 but test.check was not able to find a failing case)
Still, for some reason I get a "ClassCastException: clojure.lang.PersistentVector$Node cannot be cast to [I" for the attached 1193 element vector.
{}
(quicksort (read-string (slurp "failing-1193.edn")))
{}