How do I get something like this?
[:a 1 2 3 :b 4 5 :c 6 7 8 9 ...]
;; => {:a [1 2 3] :b [4 5] :c [6 7 8 9] ...}
This one in the cookbook is pretty easy to modify to give you want you what you are looking for. https://github.com/noprompt/meander/blob/epsilon/doc/cookbook.md#multiple-variable-length-sub-sequences
(m/rewrite [:a 1 2 3 :b 4 5 :c 6 7 8 9]
[] [] ; The base case for no values left
[(m/pred keyword? ?x) . (m/pred int? !ys) ... & ?more]
{& [[?x [!ys ...]] & (m/cata ?more)]})
I looked at this but I still have trouble bending my mind around cata & recursion
Thanks as always!
How to check if a map does not have a given key?
(m/rewrite {:m {:a 1 :b 2 :c 3}
:selector :c}
{:m {?s ?k}
:selector ?s} true)
;; => true
(m/rewrite {:m {:a 1 :b 2}
:selector :c}
{:m {?s nil}
:selector ?s} true)
;; => nil
(m/rewrite {:m {:a 1 :b 2}
:selector :c}
{:m (m/not {?s ?k})
:selector ?s} true)
;; => nil
(m/rewrite {:m {:a 1 :b 2}
:selector :d}
{:selector ?s
:m (m/not {?s (m/some)})}
true)
Just need to use a some here. Meander will match for keys that don’t exist. Changing this behavior is on my personal wish list for zeta.I was close!