You can use the interpose
function if you want a sequence, or clojure.string/join
if you just want the string result.
what is the idiomatic way to write this clojure snippet to concat collection with a string?
Question
Its best to explain what I am trying using an example.
Given a collection ["apple" "orange" "banana"] and concatenation string "," function should produce "apple,orange,banana"
Is this the idiomatic way to write this function?
user=> (defn my-concat[x st]
(str (first x) (apply str (map #(str st %) (rest x)))))
user=> (my-concat "abcd" "!")
"a!b!c!d"
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow