medley
medley copied to clipboard
Suggested addition: replace-subvec
When you need to put a vector into another vector, from start until the end of the vector to insert.
(defn replace-subvec [v v2 index]
{:pre [(vector? v)
(vector? v2)
(integer? index)]}
(let [v-count (count v)
index (if (<= index v-count)
index v-count)]
(persistent!
(reduce-kv
(fn [acc i el]
(assoc! acc (+ i index) el))
(transient v) v2))))
This function might be a little too specific for Medley.