Reputation: 1558
Given an array contains elements such as:
[":test" ":do_this" "dont" ":_another_one"]
I need to remove the :
and replace it with a empty string
which can be done using:
(clojure.string/replace element #":" "")
However how can I apply this to every element? I have looked at using the apply
function but it doesn't seem to modify the elements, is this because they are in fact immutable
?
(apply function collection)
Is what I've been looking at doing but no luck so far.
Upvotes: 2
Views: 906
Reputation: 144126
Use map
:
(let [input [":test" ":do_this" "dont" ":_another_one"]
updated (map #(clojure.string/replace % #":" "") input)]
...)
this returns a sequence instead of a vector, so use mapv
if you want to create a new vector.
Upvotes: 6