I would like to write a function replace-several that receives a string and a set of replacements and apply all the replacements (where the replacements see the result of the previous replacements).
I thought about the following interface:
(replace-several "abc" #"a" "c"
#"b" "l"
#"c" "j"); should return "jlj"
Two questions:
- Is it the most idiomatic interface in clojure?
- How to implement this function?
Remark: To make a single replacement, there is replace available in clojure.string.
Implementing @kotarak’s advice using
replace,reduceandpartition: