I'm new to Clojure and I'd like to dynamic build a vector/list.
I've built this function generate-map
that return a map
, like:
{:key 1, :value 1, :other [...]}
In this other function get-statement
, I have a doseq
calling this generate-map
function.
(defn get-statement
[st]
(doseq [s st] (generate-map s)))
I'd like to build one map joining all these generate-maps
returns over the doseq
call, e.g.:
[{:key 1, :value 1, :other [...]}
{:key 2, :value 2, :other [...]}
{:key 3, :value 3, :other [...]}]
How can I do that? Thanks!
doseq
since you need the result. Usefor
. 2. Look up theinto
function.(into {}...)
. I'd post an answer, but I'm on the clock :/ – Carcigenicatefor
. Evidently I'm tired. Not sure why my mind jumped immediately to(into [] (for ...))
.mapv
is almost definitely the right tool for the job here, unless you need some kind of filtering. – Carcigenicate