This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-16
Channels
- # aws (17)
- # babashka (2)
- # beginners (131)
- # bristol-clojurians (1)
- # calva (16)
- # chlorine-clover (6)
- # cider (10)
- # clara (5)
- # cljsrn (82)
- # clojure (176)
- # clojure-dev (14)
- # clojure-europe (13)
- # clojure-italy (13)
- # clojure-nl (4)
- # clojure-spec (10)
- # clojure-sweden (32)
- # clojure-uk (32)
- # clojuredesign-podcast (2)
- # clojurescript (34)
- # community-development (2)
- # conjure (17)
- # cursive (4)
- # datomic (51)
- # emacs (6)
- # figwheel-main (26)
- # fulcro (16)
- # graalvm (11)
- # jobs (2)
- # jobs-discuss (30)
- # kaocha (4)
- # meander (23)
- # off-topic (34)
- # pathom (5)
- # re-frame (10)
- # reagent (3)
- # reitit (6)
- # releases (3)
- # sci (36)
- # shadow-cljs (27)
- # sql (9)
- # testing (6)
- # tools-deps (28)
- # vim (8)
@noprompt quick question (sorry, no complete snippet, rushed at the moment); is it possible to destructure while "capturing" something
What you wrote there does work. Not sure what you are looking for.
the array passed in is
[{:op :ophirUseOpnDataLit,
:name :datalit_smoothArgs,
:ctypeUid {:op :ophirCuid, :cuidstr :SmoothingChop_PrmBlk_t},
:fldvalmap
{:chSmplRate {:op :ophirConst, :ctypeUid :SmplRate_t, :val 1},
:chStartSmplNum {:op :ophirConst, :ctypeUid :SmplIdx_t, :val 1}}}
{:op :ophirUseOpnode,
:name :loPass,
:opdefUid {:op :ophirOpuid, :opuidstr :smootherchop},
:oprmblkbnds
{:op :ophirOprmblkBinds,
:oprmbnds
[{:op :ophirOprmbind,
:prmname :smoothArgs,
:prmbind {:op :ophirOprmPath, :pathstr "opgrph:./opnodes/opgrphdata/smoothArgs1"}}
{:op :ophirOprmbind, :prmname :chIn, :prmbind {:op :ophirOprmPath, :pathstr "opgrph:./oprms/inBoneTrk"}}]}}
{:op :ophirUseOpnode,
:name :hiPass,
:opdefUid {:op :ophirOpuid, :opuidstr :smootherchop},
:oprmblkbnds
{:op :ophirOprmblkBinds,
:oprmbnds
[{:op :ophirOprmbind, :prmname :smoothArgs, :prmbind {:op :ophirOprmPath, :pathstr "opgrph:/loPass/@smoothArgs"}}
{:op :ophirOprmbind, :prmname :chIn, :prmbind {:op :ophirOprmPath, :pathstr "opgrph:/loPass/@chOut"}}]}}]
And you want to get only the ones with a certain op?
i want to extract out {:name :ctypeUid} from the meander filter (but only if it's :op == :ophirUseOpnDataLit)
You can use m/gather
.
i can't figure out how to "crack open" the inner parts through a destructure while keeping a memory variable
It is like filter.
thnx! will come back tonight and update the sample PR with it or ask questions if i stumble
Sounds good.
I think I'm being stupid here, but I'm not sure how... I have seen this error several times now:
Execution error at scratch.overcast-xml/eval19536$fn$fn (overcast_xml.clj:29).
Can't remove struct key
I've solved it a few times now, but I'm still not sure what the causal pattern it is. Here is my most recent example:
(m/search file ; some xml, can provide a subset if needed
(m/$ {:attrs {:xmlUrl (m/some ?rss-feed)}
:content (m/scan {:tag :outline
:attrs !attrs})})
{:rss ?rss-feed :attrs !attrs})
@jatkin There might be something up how Meander is interacting with the XML library. Do you have, perhaps, a deps.edn
and a minimal example that triggers this problem? Iām happy to have a look at it.
Looks like the type is clojure.lang.PersistentStructMap, which maybe doesn't allow dissocing... Which would make sense... It's just clojure.xml
Yup, that's it... Not meander š Thanks for bringing that up, would never have thought of that!
So, another possible dumb question: can I unroll results? e.g. I have a match with a capture and a memory variable. can I unroll the result with the single capture reused while all the memory vars are used? My usage rn:
(m/search xml-cleared-structs
(m/$ {:attrs {:xmlUrl (m/some ?rss-feed)}
:content (m/scan {:tag :outline
:attrs {:progress (m/some !progress)
:title (m/some !title)}}
)})
{:rss ?rss-feed :progresses !progress :titles !title})
;; =>
({:rss "",
:progresses ["3642"],
:titles ["Why Functional Programming Matters"]}
{:rss "",
:progresses ["2200" "3190"],
:titles ["My response to Out of the Tar Pit" "Another Title"]})
I got a bit closer with this:
(m/search xml-cleared-structs
(m/$ {:attrs {:xmlUrl (m/some ?rss-feed)}
:content [_ ... {:tag :outline
:attrs {:progress (m/some ?progress)
:title (m/some ?title)}}
]})
{:rss ?rss-feed :progresses ?progress :titles ?title})
But it only matches the last element in the :content vector