替换字符

基本类型 / 字符串

;; 字符串不可变:无法原地给某个字符赋值
(def text "1-3-2")

;; 对字符向量操作,再拼回去
(def fixed
  (apply str (-> (vec text)
                 (assoc 2 \2)
                 (assoc 4 \3))))
;; fixed is "1-2-3"

(println "text is" text)
(println "fixed is" fixed)