I'm sorry if this is a truly basic question, but some code I've seen got me curious.
What is the idiomatic usage of the apply
function?
For instance, I've seen code written in the form:
(distinct [1 2 3 4 5 6])
and
(apply distinct? [1 2 3 4 5 6])
These return the same result, and even in the docs, it clearly says:
;; Note the equivalence of the following two forms
user=> (apply str ["str1" "str2" "str3"]) "str1str2str3"
user=> (str "str1" "str2" "str3") "str1str2str3"
Is this example simply too basic to convey the usefulness of apply
? Or am I missing a fundamental difference between the two?
When is one form regarded as best over the other?