Programming

(Clojure) Simple way to replace nth element in a vector in clojure?

steloflute 2012. 12. 26. 13:07

http://stackoverflow.com/questions/12628286/simple-way-to-replace-nth-element-in-a-vector-in-clojure


assoc works fine for that. It takes the index where to put the new value and return the newly created vector:

Clojure> (assoc [1 2 3] 1 5)
[1 5 3]