data: keep mapv (vector result) — list-with-nil destructures wrong positionally

This commit is contained in:
Yogthos 2026-06-06 19:30:20 -04:00
parent bfb49f23ab
commit fc88ecdc74

View file

@ -44,12 +44,15 @@
"Diff associative things a and b, comparing only keys in ks." "Diff associative things a and b, comparing only keys in ks."
[a b ks] [a b ks]
(reduce (reduce
(fn [diff1 diff2] (doall (map merge diff1 diff2))) ;; mapv (vector result) rather than the reference's (doall (map …)): the diff
;; triples are destructured positionally and a list with a nil middle element
;; mis-binds under jolt destructuring, whereas a vector indexes cleanly.
(fn [diff1 diff2] (mapv merge diff1 diff2))
[nil nil nil] [nil nil nil]
(map (partial diff-associative-key a b) ks))) (mapv (partial diff-associative-key a b) ks)))
(defn- diff-sequential [a b] (defn- diff-sequential [a b]
(vec (map vectorize (diff-associative (vec (mapv vectorize (diff-associative
(if (vector? a) a (vec a)) (if (vector? a) a (vec a))
(if (vector? b) b (vec b)) (if (vector? b) b (vec b))
(range (max (count a) (count b))))))) (range (max (count a) (count b)))))))