Clojure将字符串替换应用于数组中的每个元素

Chr*_*rds 2 arrays clojure

给定一个数组包含如下元素:

[":test" ":do_this" "dont" ":_another_one"]
Run Code Online (Sandbox Code Playgroud)

我需要删除:并替换它empty string可以使用以下方法完成:

(clojure.string/replace element #":" "")
Run Code Online (Sandbox Code Playgroud)

但是,我如何将其应用于每个元素?我已经看过使用该apply函数但它似乎没有修改元素,这是因为它们实际上是immutable

(apply function collection)
Run Code Online (Sandbox Code Playgroud)

这是我一直在做什么但到目前为止没有运气.

Lee*_*Lee 6

用途map:

(let [input [":test" ":do_this" "dont" ":_another_one"]
      updated (map #(clojure.string/replace % #":" "") input)]
  ...)
Run Code Online (Sandbox Code Playgroud)

这将返回一个序列而不是一个向量,因此mapv如果要创建一个新向量,请使用它.