This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-11
Channels
- # beginners (132)
- # boot (2)
- # cider (17)
- # cljs-dev (6)
- # cljsrn (24)
- # clojure (134)
- # clojure-austin (2)
- # clojure-dusseldorf (11)
- # clojure-france (1)
- # clojure-greece (27)
- # clojure-italy (17)
- # clojure-madison (1)
- # clojure-russia (31)
- # clojure-serbia (1)
- # clojure-sg (2)
- # clojure-spec (30)
- # clojure-uk (66)
- # clojurescript (73)
- # core-async (2)
- # cursive (8)
- # data-science (2)
- # datomic (23)
- # dirac (8)
- # emacs (18)
- # gsoc (1)
- # hoplon (36)
- # immutant (26)
- # leiningen (6)
- # off-topic (21)
- # om (19)
- # onyx (6)
- # other-languages (1)
- # pedestal (3)
- # proton (2)
- # random (1)
- # re-frame (1)
- # reagent (2)
- # remote-jobs (2)
- # ring-swagger (8)
- # rum (21)
- # slack-help (1)
- # spacemacs (4)
- # specter (16)
- # untangled (6)
hello, I'm trying to figure if I can use specter for a situation I have here
I have a map, and I would like to filter the map by some criteria on the values
today my Clojure code is:
(->> some-map
(filter (fn [[k v]]
(> v 10)))
(into {}))
is there a way to replace this with specter select
and avoid having to convert the data types?
@wilkerlucio (transform [MAP-VALS #(> % 10)] some-map)
that will maintain the type of the map and also run about 10x faster
@nathanmarz thanks, didn't even occur to me to use transform to filter, but seeing it makes total sense 🙂
I think would be nice to have some filter
example like this on README
sorry, meant to write this: (setval [MAP-VALS #(<= % 10)] NONE some-map)
sleepy today
haha, I was just coming back to ask, thanks for the speedy catch 🙂
@nathanmarz why we need to invert the predicate?
ah, gotcha, it's not about filtering ther,e it's about removing
yea, that's right