This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-20
Channels
- # aleph (1)
- # announcements (1)
- # aws (11)
- # babashka (117)
- # beginners (34)
- # calva (13)
- # cider (3)
- # clj-commons (8)
- # clj-kondo (24)
- # clj-yaml (36)
- # cljsrn (46)
- # clojure (50)
- # clojure-australia (5)
- # clojure-europe (239)
- # clojure-nl (3)
- # clojure-norway (3)
- # clojure-spec (16)
- # clojurescript (25)
- # core-typed (20)
- # cursive (41)
- # datahike (1)
- # datalevin (1)
- # datomic (17)
- # fulcro (27)
- # hyperfiddle (35)
- # introduce-yourself (1)
- # jobs (4)
- # lsp (20)
- # malli (8)
- # meander (8)
- # nbb (1)
- # off-topic (31)
- # parinfer (9)
- # pathom (3)
- # portal (2)
- # re-frame (20)
- # react (2)
- # reagent (8)
- # releases (1)
- # remote-jobs (4)
- # scittle (2)
- # shadow-cljs (8)
- # slack-help (4)
- # sql (30)
- # squint (3)
- # tools-deps (34)
- # xtdb (21)
hello, I'm trying to use a rewrite strategy, but I notice that different than when using find
or search
, I can't have a clojure expression replacement, for example:
(let [f
(m*/bottom-up
(m*/attempt
(m*/rewrite
{:all (m/pred some?) :as ?m}
(dissoc ?m :all))))]
(f {:foo {:all "here"}}))
=> {:foo (dissoc {:all "here"} :all)}
in this case I was trying to make a meander expression that removes every :all
keys from all maps it can find
(let [f (s/bottom-up
(s/rewrite
{:all _ & ?m}
?m
?else
?else))]
(f {:foo {:all "here"}}))
^^ this is how I'd do it 🙂=> {:foo {}}
I think your version should work fine if you either used ~
to execute dissoc, or used match
instead of rewrite
i.e.:
(let [f
(s/bottom-up
(s/attempt
(s/rewrite
{:all (m/pred some?) :as ?m}
~(dissoc ?m :all))))]
(f {:foo {:all "here"}}))
=> {:foo {}}
But IMO the & thing is nicer as it keeps everything as a pattern 😉