Fork me on GitHub

If I'm trying to map over a range, and build up a single string with the result, is that the job of a reduce?


Yes. Most generally reduce is for deriving a value from a sequence.

Martin Půda16:07:34

Can you write the exact problem and expected result?


(apply str (map generate-string-with-number (range start end -1))) is what I ended up with


generate-string-with-number 2 -> "I am string number 2."


The aforementioned resulting in a single string

Martin Půda17:07:10

I think the best solution is ->> map , clojure.string/join :

(->> (range 10 5 -1)
     (map #(str "I am string number " % "."))
     (s/join " "))
You can do something like that with reduce, if you don't mind missing space between sentences (or there will be one unwanted space):
(->> (range 10 5 -1)
     (reduce #(str %1 "I am string number " %2 ".") ""))
And one more with clojure.pprint/cl-format:
(pp/cl-format nil "~{I am string number ~a.~^ ~}" (range 10 5 -1))