meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
2019-12-21T19:14:33.052100Z

I'd like to rewrite a subset of a map while maintaining any part of the map not subject to the rewrite. A simple example:

{:a "a", :b "b", :c "c"} => {:a "A", :"b", :c "c"}

2019-12-21T19:15:24.053200Z

The only key that I care about is :a so I'd like to just treat any remaining entries in a generic fashion. I'm having trouble finding the right meander magic.

2019-12-21T19:16:02.054200Z

the closest I've come is

(m/find {:a "a"
           :b "b"
           :c "c"}
    (m/and
      {:a    ?a}
      (m/seqable !kvs ...))
    [{:a (.toUpperCase ?a)} !kvs])
Which gets me kind of close but I can't help but think there's a better approach

2019-12-21T19:17:22.055400Z

Is there an operator similar to cond which only matches on the first matching expression?

noprompt 2019-12-21T20:30:54.056600Z

(m/rewrite the-map
  {:a (m/pred string? ?a) & ?the-rest}
  {:a (m/app clojure.string/upper-case ?a) & ?the-rest}

  ;; Default
  ?x
  ?x)

noprompt 2019-12-21T20:31:40.057300Z

@mark340 ☝️ that should do the trick. (Yes I know & is missing docs.)

2019-12-21T20:32:04.057800Z

Ah! & is definitely the missing piece for me. Thanks!