This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-29
Channels
- # ai (2)
- # beginners (12)
- # bitcoin (1)
- # boot (41)
- # chestnut (5)
- # cider (9)
- # clara (24)
- # cljs-dev (11)
- # clojure (107)
- # clojure-dev (2)
- # clojure-italy (4)
- # clojure-nl (4)
- # clojure-russia (10)
- # clojure-spec (19)
- # clojure-uk (71)
- # clojurescript (121)
- # cursive (3)
- # data-science (7)
- # datacrypt (1)
- # datomic (72)
- # docs (7)
- # duct (2)
- # emacs (3)
- # ethereum (1)
- # figwheel (1)
- # fulcro (58)
- # graphql (16)
- # hoplon (9)
- # jobs (2)
- # jobs-rus (1)
- # lein-figwheel (1)
- # leiningen (25)
- # luminus (2)
- # lumo (5)
- # off-topic (6)
- # onyx (22)
- # pedestal (3)
- # portkey (1)
- # proton (2)
- # re-frame (7)
- # remote-jobs (1)
- # ring-swagger (3)
- # rum (2)
- # shadow-cljs (38)
- # specter (7)
- # yada (30)
Hi there, I'm having trouble doing the following:
;; Considering this map m
(def m {:a 3
:b {10 {:c 3}
2 {:d 4}
20 {:c 5}}})
;; I'd like to remove entries in the :b map if
;; the key is < 15
;; and
;; the value doesn't contain :d
;; so it's like:
; {:a 3
; :b {2 {:d 4}
; 20 {:c 5}}}
I managed to do it with (sp/setval [:b sp/ALL (fn [[k v]] (and (< k 15) (not (contains? v :d))))] sp/NONE m)
but I guess there could be a more elegant solution?
here's a way that doesn't use any anonymous functions:
(setval
[:b
ALL
(not-selected? LAST (must :d))
FIRST
(pred< 15)]
NONE
m)
Amazing, thanks!
I tried something with not-selected?
but I got stuck at:
(setval
[:b
(not-selected? MAP-VALS (must :d))
MAP-KEYS
(pred< 15)]
NONE
m)
that not-selected?
call is a filter on the map as a whole
using ALL
lets you test both conditions on the same entry
Neat :thumbsup: