I've been trying to map the nested values of a map within a vector into a vector of vectors without success.
The data I have is like this:
[{:country {:name "chile", :id 1},
:subcountries [{:name "talca", :id 2}
{:name "concepcion", :id 3}
{:name "puerto montt", :id 4}]}
{:country {:name "united states", :id 5},
:subcountries [{:name "boston", :id 6}
{:name "texas", :id 7}]}]
While the code I've been playing with vaguely returns an approximation of what I'm trying to get as a result:
(map
(fn [x]
(let [{{id :id name :name} :country
subcountries :subcountries} x]
[id
name
(map (fn [y] (let [{yid :id yname :yname} y] [yid yname])))]))
data)
The result I'm receiving with that is something pretty odd, since the vector I'd want to have is just a function:
([1 "chile" #function[clojure.core/map/fn--5862]]
[5 "united states" #function[clojure.core/map/fn--5862]])
What am I doing wrong?
Expected output should be something like:
[[["chile" 1] ["talca" 2] ["concepcion" 3] ["puerto montt" 4]]
[["united states" 5] ["boston" 6] ["texas" 7]]]
data
into a vector ofoption
tags (clojure script) using thename
as theinner text
and theid
as thevalue
attribute. – Karol Karol