😳 I feel like I’m missing something basic wrt vectors — I’m trying to use bottom-up for rewriting using meander.strategy.epsilon, and it works quite well and nicely, except for that one case (code in thread).
(ns mwe
(:require [meander.strategy.epsilon :as r])
(def rewrite
(r/until =
(r/bottom-up
(r/attempt
(r/trace
(r/rewrite
[{:terms !ands} ...] {:ands [!ands ...]}
;; TODO: multiple AND's are OR'ed together
))))))
(def r1
(rewrite [[{:terms :p}, {:terms :q}]]))
;; should be: `[:or [:and :p :q]]`
(def r2
(rewrite [[{:terms :p}], [{:terms :r}]]))
;; should be: `[:or [:and :p] [:and :r]]`
the result for r1 is with the current code (which is lacking all support for adding :or)
{:ands [nil]}
trace yields this, which puzzles me:
{:id t_55682, :in [{:terms :p} {:terms :q}]}
{:id t_55682, :out {:ands [:p :q]}}
{:id t_55682, :in [{:ands [:p :q]}]}
{:id t_55682, :out {:ands [nil]}}
the first rewrite perfectly covers my intention, but the second hoses it all.similarly r2,
{:ands [nil nil]}I’m aware that I probably don’t need the strategy apparatus for this simple example; but there is more to rewrite that I’ve left off the MWE — it’s also not been giving me something unexpected on that 🙃