This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-11
Channels
- # babashka (13)
- # beginners (17)
- # bristol-clojurians (1)
- # calva (23)
- # cider (5)
- # clj-kondo (32)
- # cljsrn (2)
- # clojure (167)
- # clojure-dev (23)
- # clojure-europe (6)
- # clojure-uk (8)
- # clojurescript (5)
- # cursive (7)
- # datomic (12)
- # emacs (4)
- # events (6)
- # fulcro (2)
- # graalvm (1)
- # interop (10)
- # leiningen (8)
- # local-first-clojure (1)
- # luminus (2)
- # meander (36)
- # planck (3)
- # re-frame (3)
- # reagent (3)
- # sci (2)
- # spacemacs (4)
- # sql (1)
- # test-check (6)
- # tools-deps (22)
- # xtdb (75)
@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
(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.
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.
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)))
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]}