meander

noprompt 2022-01-14T04:05:01.012600Z

(m/rewrite {:a 'a :b nil}
  {:a ?a & (m/gather [!k (m/some !v)])}
  {:a ?a & [[!k !v] ...]})
;; =>
{:a a}

(m/rewrite {:a 'a :b nil :c 'c :d nil}
  {:a ?a & (m/gather [!k (m/some !v)])}
  {:a ?a & [[!k !v] ...]})
;; =>
{:a a, :c c}

noprompt 2022-01-14T04:05:34.013200Z

You can use m/gather for this kind (it works the best for memory variables).

noprompt 2022-01-14T04:06:18.014100Z

That pattern is the same as writing

{:a ?a & (m/seqable (m/or [!k (m/some !v)] _) ...)}

noprompt 2022-01-14T04:10:08.014900Z

More verbosely

(m/rewrite {:a 'a :b nil :c 'c :d nil}
  {?k nil & (m/cata ?m)}
  ?m
  
  {?k ?v & (m/cata ?m)}
  {?k ?v & ?m}

  {}
  {})
;; =>
{:a a, :c c}
Pattern match on the ?k nil first.