I still feel a bit weird about the fact that a String is a collection of chars but you if you have any other type of collection of chars then you have to convert it to a string… and using string/join to do that feels a bit weird. TBH I think I prefer using a function called str
to do that conversion because it makes the intent super clear: I want a string here.
A string type is certainly different from other collections. A string is not considered a sequence in Clojure, however, many clojure.core functions will treat it as a sequence of characters.
The clojure.string
functions feel natural to me when you want to treat a string as a string and get a string back.
I think its can feel natural to reach for apply str
as its a very common idiom when using a collection as a number of arguments.
I recall that we did some criterium testing on apply str
and colojure.string/join
, if I remember correctly colojure.string/join
is more efficient of the two.
Its a good experiment to try with https://github.com/hugoduncan/criterium , as well as comparing reduce
expressions with apply
expressions.