Open jramosg opened 10 months ago
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.
When you need to put a vector into another vector, from start until the end of the vector to insert.