This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-04
Channels
- # announcements (1)
- # architecture (7)
- # beginners (44)
- # biff (11)
- # calva (15)
- # cider (5)
- # clerk (9)
- # clj-kondo (20)
- # clj-on-windows (19)
- # clj-yaml (2)
- # cljs-dev (39)
- # clojure (52)
- # clojure-czech (2)
- # clojure-dev (11)
- # clojure-europe (28)
- # clojure-hamburg (10)
- # clojure-hungary (3)
- # clojure-nl (1)
- # clojure-norway (59)
- # clojure-uk (5)
- # clojured (2)
- # clojurescript (33)
- # conjure (2)
- # datahike (1)
- # datomic (5)
- # defnpodcast (5)
- # emacs (18)
- # figwheel (2)
- # funcool (6)
- # graphql (1)
- # hyperfiddle (11)
- # jobs (3)
- # joyride (13)
- # malli (6)
- # music (4)
- # off-topic (45)
- # polylith (11)
- # practicalli (3)
- # rdf (3)
- # releases (1)
- # scittle (8)
- # shadow-cljs (13)
- # specter (2)
- # squint (8)
- # testing (6)
- # tools-deps (21)
- # xtdb (2)
Is there any way to edit multiple bits of a zipper in one transform? If I do something like the following I get a stack overflow 😕:
(let [s [:a [:b [1 2 3]] [:c 3 4 5]]]
(S/transform [SZ/VECTOR-ZIP
SZ/NEXT-WALK
#(= 3 (zip/node %))
SZ/NODE]
(constantly [:z 1 2 3])
s))
Obviously there are plenty of ways to do this without zippers but this is the simplest thing I can get to blow up.
If I change (constantly [:z 1 2 3])
to (constantly [:z 1 2])
then it all works fine.
My intuition would be that it finds everything in the path then applies the transform to things. But it looks like it keeps expanding the 3's until the stack gets blown.The following seems to solve this specific problem. I will see if it solved my actual problem.
(def BEFORE-END
(S/recursive-path [] p
(S/if-path #(zip/end? (zip/next %))
S/STAY
[SZ/NEXT p])))
(S/declarepath ^{:doc "Navigate to every element reachable using calls
to PREV"}
PREV-WALK)
(S/providepath PREV-WALK
(S/stay-then-continue
SZ/PREV
PREV-WALK))
(let [s [:a [:b [1 2 3]] [:c 3 4 5]]]
(S/transform [SZ/VECTOR-ZIP
BEFORE-END
PREV-WALK
#(= 3 (zip/node %))
SZ/NODE]
(constantly [:z 1 2 3])
s))