Fork me on GitHub
#specter
<
2021-09-13
>
johanatan04:09:57

that's close but not quite it. the keys need to match in both. in your example there is no correspondence between structure-1 and structure-2 since the keys do not overlap

johanatan04:09:16

i was thinking of a zipping the two structures into a sequence where each entry is a three-tuple of the following form: [materizlied_path, value_one, value_two] where either value_one or value_two could be nil when that structure does not have an entry for a specific path that the other one does.

johanatan04:09:36

then the satisfies would make sure that no nil entries exist in any of those slots for my particular application

Joshua Suskalo15:09:02

Ah, that was unclear from your initial description of the problem. I don't believe specter has a way for you to get a pair of the actual path followed along with the value, which means you would likely need to generate a list of possible paths and iterate over them manually.

Joshua Suskalo15:09:29

Specifically, you could have a way to generate a "materialized path" from each of the types of navigations which navigate to multiple items. Like ALL generating a sequence of paths with nth being called for each integer in (range 0 (count structure)), or MAP-VALS generating a sequence of the keys.

johanatan17:09:17

Pretty sure it wasn't "unclear from my initial description". Please re-read. Pay particular attention to: a) verify that the same key structure exists in both

johanatan17:09:05

Ok, yes looks like a challenge wrt generating (or iterating) the paths but that seems surmountable.

johanatan17:09:41

Thanks for your help!

Joshua Suskalo19:09:24

No problem! Might just be I read that different because even on re-reading it didn't seem clear to me. Definitely not a huge concern though, it got worked out! 🙂

johanatan19:09:28

btw, i just realized that i already have this keys-in function in my codebase (based on tree-seq), so i probably don't really even need specter for this: https://dnaeon.github.io/clojure-map-ks-paths/

johanatan19:09:03

i can just get the key sequence paths for m1 and then call get-in for each of them on m2

👍 2
johanatan22:09:02

arguably not nearly as elegant as whatever the specter solution would be tho 🙂

steveb8n23:09:09

Q: I’m using a multi-path in a recursive path similar to this example https://github.com/redplanetlabs/specter/wiki/Using-Specter-Recursively#recursively-navigate-to-every-map-in-a-map-of-maps I just discovered that my multi-path expression is working on jvm but not on javascript. The problem seems to be that I have 20 values in the multi-path. has anyone seen a limit of 20 in paths failing like this before?

steveb8n23:09:38

I also discovered that 21 values in multi-path fails on cljs with “invalid arity” but not on jvm

steveb8n23:09:08

workaround: compose the multi-path out of other multi-paths

steveb8n23:09:31

the bug is that the 20th entry is ignored when used in cljs. if there’s 19 entries then it is fine

steveb8n23:09:12

asking here before I log a bug, just so I know I’m not missing something stoopid

steveb8n00:09:41

@U173SEFUN do you care about edge case bugs like this?

johanatan00:09:26

i highly doubt that resource limitations of modern computers really justify that maximum being 20. probably could be just fine with 127 or 1023

johanatan00:09:41

and way more generous to users

johanatan00:09:56

just to throw my two cents in

nathanmarz01:09:55

@U0510KXTU please file a bug report

steveb8n01:09:26

roger that. will do