outer joins? I have two lists that I'd like to merge. is there a convenient way of expressing an outer join in meander?
Also, I'm surprised that the output of this is an empty list:
(m/search {:a [1 2 3] :b []}
{:a (m/scan ?a)
:b (m/scan ?b)}
[?a ?b])
This works:
(m/search {:a [1 2 3] :b []}
{:a (m/scan ?a)
:b (m/or
(m/scan ?b)
(m/let [?b []]))}
[?a ?b])
and I guess I'm not so surprised that the first one results in an empty listYeah before you were trying to find a ?b in that vector and there just wasn't any. So it couldn't produce any values.
Makes sense
(m/match {1 2, 3 4} {!k !v} [!k !v])
says "map patterns may not contain variables in their keys that would make it so there is more than one match possible". To me, it seems analagous to (m/match [1 2 3] [!x ...] !x)
.
Also (m/search {1 2, 3 4} {!k !v} [!k !v]) ;=> ([[3] [4]] [[1] [2]])
...
Tried on .311 and .331
Seqable might be useful here. It can do what you are looking to do with your first example.
oh, right.
Maybe its time to add map-of
?
There’s and open ticket for that and I can’t think of an alternative implementation other than the one I posted.
I think
{& [[!k !v] ...]}
should be legalized.I think I could take that, and it would do me good. I also want it in m/subst.
It does work for m/subst
😂
I’m suppose to have documented that this week. 😐
map-of does? (cause (let [!k [1 2] !v [3 4]] (m/subst {!k !v})) ;=> {1 3}
)
This is why my title is “Minimum Viable Person” 😆
(m/defsyntax map-of [k-pattern v-pattern]
(if (m/match-syntax? &env)
`(m/with [%map# {~k-pattern ~v-pattern & (m/or '{} %map#)}]
%map#)
&form))
☝️ from the ticket.
Sorry thats for match.
Ok, I'm happy to take this on. I need to learn meander syntax :D
(let [!ks [:a :b :c]
!vs [1 2 3]]
(m/subst {& [[!ks !vs] ...]}))
;; =>
{:a 1, :b 2, :c 3}
(let [!es [[:a 1] [:b 2] [:c 3]]]
(m/subst {& [!es ...]}))
;; =>
{:a 1, :b 2, :c 3}
&
amounts to into
for subst
.
I just haven’t gotten around to making that a thing proper for match syntax.