用索引处的另一个序列替换部分序列

Replace part of Sequence with another Sequence at Index

有没有一种简单的方法可以在指定位置用另一个序列替换一个序列的一部分?

(def s1 '(1 2 3 4 5 6))
(def s2 '(:a :b :c))
(insert s1 s2 2)

; => (1 2 :a :b :c 6)

一种方法是:

(defn insert [a b idx]
  (let [h (take idx a)
        t (drop (+ idx (count b)) a)]
    (concat h b t)))