@noprompt quick question (sorry, no complete snippet, rushed at the moment); is it possible to destructure while "capturing" something
ex:
[ {:op :ophirUseOpnDataLit :as !opdataLits} ...]
What you wrote there does work. Not sure what you are looking for.
oops, @jimmy sorry pasted too soon
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.
ah brilliant; let me look that up
thnx! will come back tonight and update the sample PR with it or ask questions if i stumble
(trying to check something in in <1hr š¤ )
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 "<https://feeds.transistor.fm/thoughts-on-functional-programming-podcast-by-eric-normand>",
:progresses ["3642"],
:titles ["Why Functional Programming Matters"]}
{:rss "<https://feeds.transistor.fm/thoughts-on-functional-programming-podcast-by-eric-normand>",
:progresses ["2200" "3190"],
:titles ["My response to Out of the Tar Pit" "Another Title"]})
Is the value on the right of the =>
the expected?
The actual
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 vectorHaven't figured out how to put the zero or more in the right place for this to match everything correctly