(defn replace-nth [col n v] (let [index (dec n) eq? (partial = index) to (empty col)] (into to (map #(if (eq? %2) v %1) col (range))))) (replace-nth [7 1 2 3 4 5 6 8] 4 "tttt")