@noprompt added a new example: Split stream based on filter and project https://github.com/noprompt/meander/blob/e562f563c42adf3763919dc7fb9cbab3b9c19b24/doc/cookbook.md#transform slowly getting the hang of things
part i struggled with is applying an or predicate on a pattern that can match multiple times
ie, i have an array of objects with a bitflag (possible values: EArgIn, EArgIn |EArgOut, EArgOut
)
i want to split them into an arg array of inputs and outputs but fields that had ArgIn|ArgOut
would only show up in one of the arrays
Are you still struggling with this?
heh, yeah. i finally gave up on it
Ha!
and marked "feature not supported" š
(obvi jk, but i just let it be for now)
(meta: i also have to say I absolutely love once I manage to get things in meander. everything is instantly grokkable days later)
Sure, sure. If you have a vanilla Clojure implementation and I might be able to supply a pattern for it.
Iām really excited about the stuff youāre playing around with e.g. the C++ stuff because, really, this was the kind of space I wanted Meander to fit in to i.e. AST transforms, etc.
yeah, it's literally the whole reason i'm using it
i always hate how complicated term rewriting was for basic things
re: code - sure, it's in the link. i tried to make it self contained so you can copy paste it
Gradually, Iām realizing that what I want is essentially a DCG sort of thing but richer a bit different from whats on offer in Prolog and integrated with Clojure.
each variant is a different tactic i tried (i kept it in the doc bc it helps shows the difference between {search , match} x {memory vars, logic vars}
I should have some more time over the weekend to review stuff, help with questions, etc.
sure, np
Youāve captured my attention. š
and no rush; i basically just queue up everything and using that PR as a working draft
my goal is once I finish writing this part of my dsl compiler in clojure to come back and edit the PR draft to final form
Sure. Just let me know what you need on that e.g. āCan you fill in this blank or that blank?ā sort of thing.
š
For stuff youāre stuck on, a Clojure implementation can help. If I canāt map it, Iāll be honest about that.
would you prefer a straight clojure implementation or is higher level pseudocode better?
ex: I wrote this as what i was trying to do and then tried to figure out how to get meander to map it
filter(
(predA? x) => (projA x) :as !projAseq
(predB? x) => (projB x) :as !projBseq
)
So I think that is
(m/or (m/pred predA? (m/app projA !projASeq))
(m/pred predB? (m/app projB !projBSeq)))
Either is fine though, if Iām confused Iāll ask. š
hmm, still can't get it to work
Simplified snippet:
(def arglist [{:name :inBoneTrk :argFlags #{:EArg-In}}
{:name :inoutBoneTrk :argFlags #{:EArg-In :EArg-Out}}
{:name :outBoneTrk :argFlags #{:EArg-Out}}])
(m/match
arglist
[(m/or (m/pred #(contains? %1 :EArg-In) (m/app :name !projASeq))
(m/pred #(contains? %1 :EArg-Out) (m/app :name !projBSeq)))
...]
{:in-args !projASeq
:out-args !projBSeq})
Actual: Error: nonĀ exhaustiveĀ patternĀ match
Expected:
{:in-args [:inBoneTrk :inoutBoneTrk]
:out-args [:outBoneTrk :inoutBoneTrk]}
(let [arglist [{:name :inBoneTrk :argFlags #{:EArg-In}}
{:name :inoutBoneTrk :argFlags #{:EArg-In :EArg-Out}}
{:name :outBoneTrk :argFlags #{:EArg-Out}}]]
(m/find arglist
[(m/and (m/or {:argFlags #{:EArg-In} :name !projASeq} _)
(m/or {:argFlags #{:EArg-Out} :name !projBSeq} _))
...]
{:in-args !projASeq
:out-args !projBSeq}))
;; =>
{:in-args [:inBoneTrk :inoutBoneTrk],
:out-args [:inoutBoneTrk :outBoneTrk]}
You could use match
instead of find
in this case if you want āblow upā semantics.
Alternatively
[(m/or {:argFlags #{:EArg-In :EArg-Out} :name (m/and !projASeq !projBSeq)}
{:argFlags #{:EArg-In}, :name !projASeq}
{:argFlags #{:EArg-Out}, :name !projBSeq})
...]
works.š