data: keep mapv (vector result) — list-with-nil destructures wrong positionally
This commit is contained in:
parent
bfb49f23ab
commit
fc88ecdc74
1 changed files with 9 additions and 6 deletions
|
|
@ -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)))))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue