Reputation: 25
(def input (atom[
#{
[
{:site-id 1}
{:both-unconf [[27 4] "Humidity"]}
{:own-unconf|other-conf [[30 1] "Humidity"]}
{:other-site-unconf 2500}
{:other-site-conf 2500}
[
{:site-id 0}
{:both-unconf [[20 1] "Temperature"]}
{:own-unconf|other-conf [[22 0] "Temperature"]}
{:other-site-unconf 3}
{:other-site-conf 1}
]
]
} :something-else
]))
I want to access site-id from this atom map.
I am using the following code but not getting the output.
(->> @input
(map #(:site-id %))
(into [])
Upvotes: 0
Views: 231
Reputation: 51501
(def input
(atom [#{[{:site-id 1}
{:both-unconf [[27 4] "Humidity"]}
{:own-unconf|other-conf [[30 1] "Humidity"]}
{:other-site-unconf 2500}
{:other-site-conf 2500}
[{:site-id 0}
{:both-unconf [[20 1] "Temperature"]}
{:own-unconf|other-conf [[22 0] "Temperature"]}
{:other-site-unconf 3}
{:other-site-conf 1}]]}
:something-else]))
This data structure is very strange. It is
If we allow for the :something-else
to be something else, it should be, to be useful:
So:
(def input
(atom [#{{:site-id 1
:both-unconf [[27 4] "Humidity"]
:own-unconf|other-conf [[30 1] "Humidity"]
:other-site-unconf 2500
:other-site-conf 2500}
{:site-id 0
:both-unconf [[20 1] "Temperature"]
:own-unconf|other-conf [[22 0] "Temperature"]
:other-site-unconf 3
:other-site-conf 1}}
:something-else]))
If it was like this, then
(->> @input
first
(mapv :site-id))
would work.
Upvotes: 1