This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-15
Channels
- # admin-announcements (25)
- # beginners (21)
- # boot (487)
- # cider (8)
- # clara (2)
- # cljsrn (35)
- # clojure (44)
- # clojure-austin (6)
- # clojure-russia (211)
- # clojure-uk (25)
- # clojurescript (225)
- # core-matrix (1)
- # data-science (3)
- # datomic (23)
- # events (1)
- # hoplon (9)
- # immutant (14)
- # jobs (1)
- # jobs-discuss (5)
- # ldnclj (3)
- # lein-figwheel (2)
- # off-topic (2)
- # om (65)
- # onyx (65)
- # parinfer (3)
- # pedestal (4)
- # proton (1)
- # protorepl (1)
- # re-frame (16)
- # reagent (3)
- # ring-swagger (1)
- # specter (11)
- # untangled (1)
- # yada (8)
I have a basic specter question. I think I'm just not understanding its fundamental concepts.
Say I have a vector mymaps
like so:
(def mymaps [{:a 1 :b 2 :c {:d true}}
{:a 2 :b 2 :c {:d false}}
{:a 3 :b 2 :c {:d true}}])
And I want to select all the items where the nested map's :d's value is true. If I was using filter
and get-in
, I'd just do it like so:
(filter #(get-in % [:c :d]) mymaps)
How would I do this with specter?
I'm supposing I should use the select
operator, since I don't want to transform components of the original structure in place. I only want to select certain components within it.
So, trivially, I could use select to pull out all the boolean values I want to test, by doing:
(select [ALL :c :d] mymaps)
But this just gives me an array of booleans.
If I want to use those values as a predicate to select the maps themselves, then ... ?