This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-25
Channels
- # babashka (65)
- # beginners (34)
- # biff (18)
- # calva (8)
- # clara (22)
- # clj-kondo (32)
- # clojure (24)
- # clojure-bay-area (4)
- # clojure-europe (135)
- # clojure-nl (3)
- # clojure-norway (9)
- # clojure-uk (1)
- # clojurescript (11)
- # clojutre (1)
- # core-async (8)
- # cursive (3)
- # datomic (31)
- # emacs (5)
- # fulcro (6)
- # graalvm (5)
- # graphql (3)
- # honeysql (1)
- # introduce-yourself (9)
- # kaocha (1)
- # lsp (65)
- # meander (5)
- # nbb (7)
- # nrepl (2)
- # off-topic (44)
- # rum (3)
- # shadow-cljs (23)
- # specter (1)
- # tools-deps (6)
- # vim (3)
- # xtdb (30)
Hey, I think I'm having a very basic question. I want to effectively keep a sequence a sequence inside a meander/match
while rewriting the contents of the sequence. This is what I've got so far but it still needs post-processing (which I'm okay with doing in clojure code, but I feel like I'm missing a piece of meander understanding):
(meander/search {:foo 1
:bar 2
:baz 3
:lst [{:id 1, :name "a"}
{:id 2, :name "b"}
{:id 3, :name "c"}]}
{:foo ?foo
:bar ?bar
:baz ?baz
:lst (meander/scan {:id ?el-id
:name ?el-name})}
{:example/foo ?foo
:example/bar ?bar
:example/baz ?baz
:example/list [{:example.list/id ?el-id
:example.list/name ?el-name}]})
✅ 1
I would like the output to be:
{:example/foo 1, :example/bar 2, :example/baz 3
:example/list [{:example.list/id 1, :example.list/name "a"}
{:example.list/id 2, :example.list/name "b"}
{:example.list/id 3, :example.list/name "c"}]}
(m/rewrite {:foo 1
:bar 2
:baz 3
:lst [{:id 1, :name "a"}
{:id 2, :name "b"}
{:id 3, :name "c"}]}
{:foo ?foo
:bar ?bar
:baz ?baz
:lst [{:id !el-id
:name !el-name} ...]}
{:example/foo ?foo
:example/bar ?bar
:example/baz ?baz
:example/list [{:example.list/id !el-id
:example.list/name !el-name} ...]})
=>
#:example{:foo 1,
:bar 2,
:baz 3,
:list [#:example.list{:id 1, :name "a"} #:example.list{:id 2, :name "b"} #:example.list{:id 3, :name "c"}]}