Here are at least two things you can do to make this a tad bit more percise. First you can just use get directly, rather than binding a function.
(defn oprmbinds-mk [a_arg]
(m/rewrite a_arg
(:makeparmbinds ?valmap [{(m/or :name :fldname) (m/and !prmn1 !prmn2 !prmn3)
:ctype {:ctuid !prmctuid}} ...])
(m/map-of !prmn1 {:prmName !prmn2
:prmCtuid !prmctuid
:prmBind (m/app get ?valmap !prmn3 :prmbnd-none)})))
But technically, you don’t even need the get, maps are functions themselves.
(defn oprmbinds-mk [a_arg]
(m/rewrite a_arg
(:makeparmbinds ?valmap [{(m/or :name :fldname) (m/and !prmn1 !prmn2 !prmn3)
:ctype {:ctuid !prmctuid}} ...])
(m/map-of !prmn1 {:prmName !prmn2
:prmCtuid !prmctuid
:prmBind (m/app ?valmap !prmn3 :prmbnd-none)})))
I tried doing this with rewrites, and there is definitely a way, but I still ended up using the same little app trick.
As for joins and stuff, those work fairly well with search/rewrites unless you want to do things like a default value if something doesn’t exist (like you are doing here). I played with trying to make it work with an explicit join and sadly came up a bit short. Through the m/app
trick above would work, I was sad I couldn’t express it more directly.
(into {}
(m/rewrites a_arg
(:makeparmbinds {?param ?val}
(m/scan {(m/or :name :fldname) ?param
:ctype {:ctuid ?prmctuid}}))
[?param {:prmName ?param
:prmCtuid ?prmctuid
:prmBind ?val}]))
(into {} (m/search {:a nil :b 10 :c 20 :d nil}
{?k (m/some ?v)} {?k ?v})) ;; {:b 10, :c 20}
I feel like there's going to be a neater solution to this?(m/rewrite {:a nil :b 10 :c 20 :d nil}
(m/gather [!k (m/some !v)])
{& [[!k !v] ...]})
There's another way of doing it.Oh wait, forgot about map-of
(m/rewrite {:a nil :b 10 :c 20 :d nil}
(m/gather [!k (m/some !v)])
(m/map-of !k !v))
ah, so gather is the proper way to collect the keys such that I can then map-of with them. I tried map-of a lot and got nowhere.
I'm guessing gather actually iterates, whereas search is going pair-by-pair?
Yeah in this case gather is equivalent to
(m/rewrite {:a nil :b 10 :c 20 :d nil}
(m/seqable (m/or [!k (m/some !v)] _) ...)
(m/map-of !k !v))