This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-17
Channels
- # aleph (3)
- # bangalore-clj (2)
- # beginners (76)
- # boot (37)
- # braid-chat (7)
- # business (1)
- # clara (1)
- # cljsrn (45)
- # clojure (36)
- # clojure-android (1)
- # clojure-austin (2)
- # clojure-dusseldorf (4)
- # clojure-spec (2)
- # clojure-uk (2)
- # clojurebridge-ams (4)
- # clojurescript (79)
- # clr (1)
- # community-development (5)
- # core-async (1)
- # cursive (4)
- # data-science (1)
- # funcool (3)
- # hoplon (3)
- # om (107)
- # om-next (6)
- # other-lisps (1)
- # overtone (1)
- # planck (2)
- # reagent (24)
- # rum (1)
- # specter (7)
- # yada (46)
hey guys, is there an idiomatic way to select a slice of a nested map given a predicate for some level? for example, using even?
, {:a {:b 1, :c 2}, :d {:e 3, :f 4}, :g {:h 5}}
-> {:a {:c 2} :d {:f 4}}
so far I have something like this, which is pretty close:
(transform [MAP-VALS]
#(into {}
(select-one (filterer LAST even?) %))
ex)
the (into {} … )
doesn’t seem like the best solution. maybe if there were a type-aware select
? seems to be an issue from a while back here: https://github.com/nathanmarz/specter/issues/127
@karan sounds like that would be a variant on submap
that takes in a path to evaluate the vals, e.g. (filtered-submap even?)
or (filtered-submap (filterer even?) (view count) #(>= % 2))
see selected?
implementation for an example of a navigator which uses a path
@nathanmarz thanks, I’ll try that!