meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
2019-12-10T16:04:12.446300Z

outer joins? I have two lists that I'd like to merge. is there a convenient way of expressing an outer join in meander?

2019-12-10T16:28:02.446500Z

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

2019-12-10T16:33:57.447700Z

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 list

jimmy 2019-12-10T16:35:59.448700Z

Yeah before you were trying to find a ?b in that vector and there just wasn't any. So it couldn't produce any values.

2019-12-10T16:40:56.449Z

Makes sense

eraserhd 2019-12-10T21:42:21.451700Z

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

eraserhd 2019-12-10T21:43:29.452100Z

Also (m/search {1 2, 3 4} {!k !v} [!k !v]) ;=> ([[3] [4]] [[1] [2]])...

eraserhd 2019-12-10T21:43:55.452300Z

Tried on .311 and .331

jimmy 2019-12-10T21:52:45.454600Z

Seqable might be useful here. It can do what you are looking to do with your first example.

eraserhd 2019-12-10T21:53:12.454800Z

oh, right.

noprompt 2019-12-10T21:53:31.455400Z

Maybe its time to add map-of?

noprompt 2019-12-10T21:54:01.455900Z

There’s and open ticket for that and I can’t think of an alternative implementation other than the one I posted.

noprompt 2019-12-10T21:55:38.457500Z

I think

{& [[!k !v] ...]}
should be legalized.

eraserhd 2019-12-10T21:55:57.458Z

I think I could take that, and it would do me good. I also want it in m/subst.

noprompt 2019-12-10T21:56:11.458500Z

It does work for m/subst 😂

noprompt 2019-12-10T21:56:25.459Z

I’m suppose to have documented that this week. 😐

eraserhd 2019-12-10T21:57:05.460400Z

map-of does? (cause (let [!k [1 2] !v [3 4]] (m/subst {!k !v})) ;=> {1 3})

noprompt 2019-12-10T21:57:08.460600Z

This is why my title is “Minimum Viable Person” 😆

noprompt 2019-12-10T21:57:40.461Z

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

noprompt 2019-12-10T21:57:43.461200Z

☝️ from the ticket.

noprompt 2019-12-10T21:58:53.462Z

Sorry thats for match.

eraserhd 2019-12-10T21:59:39.462500Z

Ok, I'm happy to take this on. I need to learn meander syntax :D

noprompt 2019-12-10T21:59:59.462800Z

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

noprompt 2019-12-10T22:00:18.463200Z

& amounts to into for subst.

noprompt 2019-12-10T22:01:23.464200Z

I just haven’t gotten around to making that a thing proper for match syntax.