meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
zane 2020-01-18T01:32:21.005500Z

Is <pattern> ..1 the idiomatic way to express a subpattern there may or not be one of?

jimmy 2020-01-18T01:35:20.006900Z

That would be one or more repeated. Thing + in regex. If you have an example I context I'm sure we could help with the way to express what you are looking for.

zane 2020-01-18T01:43:50.007100Z

Iโ€™m looking for ? from regex, basically.

timothypratley 2020-01-19T04:28:14.019500Z

there is a way to emulate ? though itโ€™s not very obviousโ€ฆ consider this pattern: (m/and [1 2 . !?x ... :a :b] (m/guard (<= (count !?x) 1)) I wish there was a more compact way ๐Ÿ™‚

1
timothypratley 2020-01-19T04:30:21.019700Z

!?x will be a memory variable (array) of either 1 value or empty.

timothypratley 2020-01-19T04:33:06.020Z

for a more complete example https://github.com/timothypratley/justice/blob/master/src/justice/defn.cljc

jimmy 2020-01-18T01:45:57.009600Z

Right now there is no direct way to say that. It depends on the context you are in. It is something we definitely have considered. But it is sadly a little complicated. In most cases you can use m/or or you can use multiple patterns to get what you are looking for.

zane 2020-01-18T01:59:22.009900Z

Got it! Thanks.

๐Ÿ‘ 1
zane 2020-01-18T02:09:58.010600Z

Iโ€™m a bit confused with how m/search and m/scan interact with memory variables.

zane 2020-01-18T02:10:43.011100Z

Firstly, is it okay to use m/search and m/scan with memory variables?

jimmy 2020-01-18T02:18:08.013100Z

Yeah it is perfectly find to use those together. Depending on how you use it, you can get different outcomes. For example here I can find all the subvectors (for lack of a better term) of a vector that contain 1 or more even numbers.

(m/search [1 2 4 5 7 6 8]
  (m/scan (m/pred even? !xs) ..1)
  !xs)

;; => 

([2] [2 4] [4] [6] [6 8] [8])

jimmy 2020-01-18T02:19:39.013800Z

If something isnโ€™t okay to use together, we try to tell you that. Like scan cannot be used with match and you will get an error.

zane 2020-01-18T02:59:43.014700Z

Why would this match

(m/match [:d {}]
  [:d {}]
  :e)
but this not match
(m/match [:d {}]
  [:b [(m/or [:f !c] _) ...]]
  !c

  [:d {}]
  :e)
?

zane 2020-01-18T03:01:16.015Z

Getting rid of the m/or seems to resolve the issue, but I donโ€™t understand why.

zane 2020-01-18T03:01:51.015200Z

I would have expected that adding another clause would have no effect on the subsequent clauses.

zane 2020-01-18T03:01:58.015400Z

That is to say, I thought it tried all the clauses in order?

jimmy 2020-01-18T03:05:34.015600Z

That honestly seems like a bug to me. I will look into what is going on.

jimmy 2020-01-18T03:12:24.015800Z

Yeah definitely a bug. Very strange one. Going to see in the time I have if I can track it down and fix it.

jimmy 2020-01-18T03:12:29.016Z

Sorry you ran into that.

zane 2020-01-18T03:24:42.016600Z

No worries! Should I file an issue?

jimmy 2020-01-18T03:34:32.016800Z

I found the problem and have a fix for it. Will push it up and have @noprompt teach me how to make a release so I can stop bothering him to do it ๐Ÿ™‚ Thanks for offering though

1
๐Ÿ˜‚ 1
noprompt 2020-01-18T04:37:03.017600Z

[meander/epsilon "0.0.378"]

๐Ÿ‘ 1
jimmy 2020-01-18T04:38:39.017900Z

@zane Bug is fixed here

zane 2020-01-18T04:38:46.018100Z

That was so fast! Thanks, @jimmy and @noprompt.

๐Ÿ™‚ 1
zane 2020-01-18T04:39:24.018400Z

I might look up the bugfix because I'm curious.

noprompt 2020-01-18T04:39:28.018600Z

We take bugs seriously and try to remedy them as quickly as possible. ๐Ÿ˜„

1
jimmy 2020-01-18T04:43:34.019100Z

I caused the bug before by not thinking clearly about type inference across multiple matches. This code was wrong as soon as I wrote it. So deleting it was the best option.