meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
2021-02-03T00:11:46.016300Z

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] ...}

jimmy 2021-02-03T03:48:15.017Z

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)]})

2021-02-03T07:05:27.017400Z

I looked at this but I still have trouble bending my mind around cata & recursion

2021-02-03T07:05:42.017600Z

Thanks as always!

2021-02-03T19:44:01.018300Z

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

jimmy 2021-02-03T20:15:36.018400Z

(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.

2021-02-03T20:24:00.018600Z

I was close!