Reputation: 196
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"
Upvotes: 1
Views: 177
Reputation: 5231
You can use the interpose
function if you want a sequence, or clojure.string/join
if you just want the string result.
Upvotes: 3