I finally have a real use-case for Meander! 🎉
I’ve already managed to do what I want, which is great, but is there any way to remove the duplication in this rewrite?
(m*/rewrite
[:and [!as ...]] [:and . !as ...]
[:or [!as ...]] [:or . !as ...]))
basically, :and
and :or
are both operators, so the pattern should be, “if the first element is an operator…”
Do you have a defined set of operators you want to match on?
yes, the set of operators is fixed!
On my phone, but you should be able to do (m/pred #{:and :or} ?op)
worked like a charm, thanks! 🚀
follow-up: is there any way to bind this pattern to a name so I can re-use it in all the rules without re-typing it?
I tried m/let
but at least on my first attempt it didn’t do the trick
You can use with https://cljdoc.org/d/meander/epsilon/0.0.512/doc/operator-overview#with