This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-09
Channels
- # beginners (22)
- # boot (80)
- # cider (6)
- # cljs-dev (5)
- # clojure (190)
- # clojure-berlin (5)
- # clojure-dev (24)
- # clojure-italy (14)
- # clojure-russia (70)
- # clojure-spec (39)
- # clojure-uk (82)
- # clojurescript (121)
- # clojurewest (1)
- # core-logic (2)
- # cursive (25)
- # datascript (186)
- # datomic (33)
- # dirac (266)
- # emacs (9)
- # gsoc (4)
- # hoplon (37)
- # immutant (34)
- # instaparse (22)
- # jobs (4)
- # juxt (6)
- # lambdaisland (2)
- # leiningen (1)
- # liberator (1)
- # luminus (5)
- # lumo (28)
- # off-topic (9)
- # om (23)
- # onyx (26)
- # other-lisps (1)
- # parinfer (39)
- # pedestal (45)
- # proton (1)
- # protorepl (10)
- # re-frame (18)
- # reagent (4)
- # ring-swagger (8)
- # rum (4)
- # specter (13)
- # test-check (14)
- # testing (1)
- # unrepl (164)
- # untangled (10)
- # yada (14)
I am trying to filter a map, but return a map, not just the filtered values. I can use setval, but how do I go one level deep?
{:id1 {:a false} :id2 {:a true}} -> {:id2 {:a true}}
using something like (setval [MAP-VALS :a true?] ....)
@chromalchemy I think you're looking for:
(setval [MAP-VALS (selected? :a (complement identity))] NONE data)
Perfect Thanks!!! Trying to understand (selected?)
. What is the difference between [ALL even?]
and [ALL (selected? even?)]
?
those particular examples are equivalent
selected?
in general is a filter on whether the path selects anything
if you only give it functions it's the same as just using those functions directly in the path
Ok so if the path does not "select" a thing, then it is effectively filtered out of the result.
Thank you again for Specter and the recent push to 1.0!!! I was surprised to read the consternated feedback on reddit. As a relative noob, it is for me much more obvious and empowering than than the walls I regularly run into when trying to juggle basic clojure functions to screen and transform data for UI stuff in cljs.
Still a bit confused why
(setval
[MAP-VALS (selected? :a true?)]
NONE
{:id1 {:a false} :id2 {:a true}})
returns {:id1 {:a false}}
But i'm up an running nonetheless I guess NONE
gets rid of the maps that pass the true?
test.
@chromalchemy yes, that's right
that code is selecting which values to remove (as opposed to which values to keep)
Ok , got it. Thx for the clarification.