This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-13
Channels
- # announcements (2)
- # aws (4)
- # babashka (14)
- # beginners (186)
- # cljdoc (2)
- # cljsrn (7)
- # clojure (56)
- # clojure-austin (1)
- # clojure-australia (2)
- # clojure-europe (46)
- # clojure-france (5)
- # clojure-nl (16)
- # clojure-norway (7)
- # clojure-spec (76)
- # clojure-sweden (15)
- # clojure-uk (13)
- # clojurescript (60)
- # code-reviews (2)
- # conjure (8)
- # datascript (1)
- # datomic (4)
- # depstar (10)
- # emacs (9)
- # events (4)
- # exercism (1)
- # fulcro (36)
- # graalvm (8)
- # introduce-yourself (3)
- # jobs-discuss (2)
- # kaocha (14)
- # lsp (1)
- # minecraft (8)
- # new-channels (1)
- # off-topic (3)
- # pathom (6)
- # polylith (9)
- # re-frame (48)
- # shadow-cljs (5)
- # specter (26)
- # tools-deps (19)
- # vim (2)
- # vscode (1)
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
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.
then the satisfies
would make sure that no nil
entries exist in any of those slots for my particular application
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.
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.
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
Ok, yes looks like a challenge wrt generating (or iterating) the paths but that seems surmountable.
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! 🙂
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/
i can just get the key sequence paths for m1 and then call get-in
for each of them on m2
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?
I also discovered that 21 values in multi-path fails on cljs with “invalid arity” but not on jvm
I wonder if this is the reason? https://github.com/redplanetlabs/specter/blob/master/src/clj/com/rpl/specter/util_macros.clj#L18
the bug is that the 20th entry is ignored when used in cljs. if there’s 19 entries then it is fine
@U173SEFUN do you care about edge case bugs like this?
i highly doubt that resource limitations of modern computers really justify that maximum being 20
. probably could be just fine with 127
or 1023
@U0510KXTU please file a bug report