From fc88ecdc74cc6366336b0b3b5edce12d8a148ab5 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Sat, 6 Jun 2026 19:30:20 -0400 Subject: [PATCH] =?UTF-8?q?data:=20keep=20mapv=20(vector=20result)=20?= =?UTF-8?q?=E2=80=94=20list-with-nil=20destructures=20wrong=20positionally?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jolt/clojure/data.clj | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/jolt/clojure/data.clj b/src/jolt/clojure/data.clj index cfc0456..b8ec180 100644 --- a/src/jolt/clojure/data.clj +++ b/src/jolt/clojure/data.clj @@ -44,15 +44,18 @@ "Diff associative things a and b, comparing only keys in ks." [a b ks] (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] - (map (partial diff-associative-key a b) ks))) + (mapv (partial diff-associative-key a b) ks))) (defn- diff-sequential [a b] - (vec (map vectorize (diff-associative - (if (vector? a) a (vec a)) - (if (vector? b) b (vec b)) - (range (max (count a) (count b))))))) + (vec (mapv vectorize (diff-associative + (if (vector? a) a (vec a)) + (if (vector? b) b (vec b)) + (range (max (count a) (count b))))))) (defn- diff-set [a b] [(not-empty (set/difference a b))