I run into this problem a lot (more often in clojurescript) but haven't noticed how others deal with it. This is what I want:
[:div.container [:div.first "first"] [:div.second "second"] [:div.third "third"]]
And let's say I'm building it from a collection like: ["first" "second" "third"]
I'll pass the collection through a mapv
and wind up with (this code is a sketch, I'm not using it):
(mapv
#([(keyword (str "div." %)) %])
["first" "second" "third"])
=> [[:div.first "first"] [:div.second "second"] [:div.third "third"]]
And if I were to use it inside the container div, I'd get:
[:div.container [[:div.first "first"] [:div.second "second"] [:div.third "third"]]]
I've been using things like cons
to put the :div.container
at the front of the result of mapv
. But in my mind there should be a better way--like an opposite of reduce
. Is there such a thing?
Edit: I did find concat
and it looks like I've tried it before, but I get a sequence back. I want a vector. (vec (concat ... ))
is not ideal.