This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-26
Channels
- # aleph (2)
- # beginners (119)
- # boot (18)
- # cider (19)
- # cljs-dev (46)
- # cljsjs (1)
- # cljsrn (30)
- # clojure (101)
- # clojure-dusseldorf (12)
- # clojure-finland (1)
- # clojure-greece (7)
- # clojure-india (2)
- # clojure-italy (6)
- # clojure-poland (4)
- # clojure-russia (120)
- # clojure-sg (3)
- # clojure-spec (147)
- # clojure-uk (75)
- # clojurescript (86)
- # cursive (4)
- # datomic (50)
- # docker (1)
- # emacs (4)
- # juxt (51)
- # leiningen (16)
- # liberator (1)
- # luminus (1)
- # lumo (116)
- # mount (2)
- # off-topic (2)
- # onyx (38)
- # pedestal (4)
- # protorepl (2)
- # re-frame (44)
- # reagent (8)
- # ring-swagger (16)
- # schema (5)
- # specter (16)
- # test-check (226)
@nathanmarz thanks again for all the help again the other day! I just wanted to clarify one thing, this function you gave me for filtering out empty lists isn't working: (setval [LEAVES ALL #(= [] %)] NONE *map*)
. It seems like it should so I'm a bit confused.
seems to be working fine
user=> (def LEAVES
#_=> (recursive-path [] p
#_=> (if-path map?
#_=> [MAP-VALS p]
#_=> STAY
#_=> )))
#'user/LEAVES
user=> (def m {0 {1 [[1 2 3] [] [4]]} 2 [[] [] [5 6]]})
#'user/m
user=> (setval [LEAVES ALL #(= [] %)] NONE m)
{0 {1 [[1 2 3] [4]]}, 2 [[5 6]]}
Oh wait. You're filtering empty vectors inside the values. I was thinking that would filter values that were empty vectors.
if you want to filter the direct values of the maps then just remove the ALL
you can also do (setval [LEAVES (continue-then-stay ALL) #(= [] %)] NONE m)
to remove empty vectors from inside the map values and then remove key/value pairs where the value is []
Ah, I see. I just looked back at the docs. Since I'm already selecting for leaves of the maps that means ALL would go inside any collections present in the values. I assumed it meant "apply this to all leaves."
no problem
@teng srange
navigates you to a sequence, so navigating to a keyword from there doesn't make sense
I think you want: (setval [:educations (nthpath 1) :major-name] "C" data)
@nathanmarz That worked, thanks! 🙂
@nathanmarz so in the crazy nested structure of {:id "blah :children [{:id "blah2 :children [ .. ]]}
it looks like a (select-first (recursive-path [] p [(walker (fn [x] ... match an id ...) STAY]) tree)
will grab any intermediate node in that structure (and halt with the STAY) is that right?
@albaker it'll grab the first node it encounters
fyi that path isn't recursive so no reason to use recursive-path
and no reason to have the STAY
after walker