meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
JAtkins 2020-07-17T00:18:06.073100Z

I guess this is the source of my confusion. Why does the code following not return (1 2 3 4 5), but instead throw an error?

(m/search {:a [1 2 3 4 5]}
  {:a [?x ...]}
  ?x)
;; => actual
Zero or more patterns may not have references to unbound logic variables.

JAtkins 2020-07-17T00:24:00.074800Z

If I break my case down an actual usage example, this is what I have as input data:

[{:context-tag :one-to-five
  :a           [1 2 3 4 5]}
 {:context-tag :nine-to-five
  :a           [9 8 7 6 5]}]
and what I'm trying to get is this:
[[:one-to-five 1]
 [:one-to-five 2]
 [:one-to-five 3]
 [:one-to-five 4]
 [:one-to-five 5]
 [:nine-to-five 9]
 [:nine-to-five 8]
 [:nine-to-five 7]
 [:nine-to-five 6]
 [:nine-to-five 5]]

JAtkins 2020-07-17T00:24:22.075200Z

Basically unroll the relationship between the numbers and the context

jimmy 2020-07-17T00:28:22.077Z

@jatkin Thanks for giving an input and output case. I am sadly busy right now, but if someone else doesn't help you before then I can post an example tonight.

JAtkins 2020-07-17T00:29:22.077300Z

No problem, I just got off work myself.

ikrimael 2020-07-17T00:41:32.077400Z

@jatkin once you figure it out, would you mind adding your cases as examples to https://github.com/noprompt/meander/pull/125

👍 1
ikrimael 2020-07-17T01:09:27.077700Z

@noprompt cleaned up/merged feedback for the examples from the chat

👍 1
noprompt 2020-07-17T08:17:03.086900Z

Merged it!

ikrimael 2020-07-17T01:10:29.077800Z

figure it's enough of a chunk to submit; i'll start another PR for today onward

JAtkins 2020-07-17T01:27:44.078Z

Will do

JAtkins 2020-07-17T01:28:10.078500Z

Trying to read through the source and make out what should make this tick.

JAtkins 2020-07-17T01:35:11.082700Z

AH-HA!

(m/search {:context-tag :one-to-five
           :k           [:aa :bb :cc :dd :ee]}
  {:context-tag ?context
   :k           [_ ... ?k . _ ...]}
  [?context ?k])

; => 

([:one-to-five :aa] [:one-to-five :bb] [:one-to-five :cc] [:one-to-five :dd] [:one-to-five :ee])

JAtkins 2020-07-17T01:35:49.083500Z

The docstring of scan was immensely helpful. But, if I might ask, why does this work but the other cases do not?

JAtkins 2020-07-17T01:37:42.084800Z

I'm especially confused by the additional _ required. I would assume those would bind to :aa and :ee . I guess by "match anything" it means even match a blank space?

JAtkins 2020-07-17T05:17:16.086400Z

I think I just had a breakthough... Holy freaking cow is this awesome! Just wrote in 2 lines something that would easily be 15 lines of regular mapping/filtering/reducing.

🎉 3