diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a645a6..5a30868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Change Log All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). -## [4-beta9] - 2024-09-10 -- handling nils carefully in `deep-merge` +## [4-beta10] - 2024-09-10 +- ignoring nils in `deep-merge` ## [4-beta9] - 2024-09-10 - making `merge-options!` and `set-options!` calls hidden in notebooks diff --git a/dev/scicloj/kindly/gen.clj b/dev/scicloj/kindly/gen.clj index 0b713a5..949c7d7 100644 --- a/dev/scicloj/kindly/gen.clj +++ b/dev/scicloj/kindly/gen.clj @@ -80,14 +80,12 @@ (defn deep-merge \"Recursively merges maps only.\" [& xs] - (reduce (fn m [a b] - (if (and (or (nil? a) - (map? a)) - (or (nil? b) - (map? b))) - (merge-with m a b) - b)) - xs)) + (->> xs + (remove nil?) + (reduce (fn m [a b] + (if (and (map? a) (map? b)) + (merge-with m a b) + b))))) (defn get-options [] diff --git a/src/scicloj/kindly/v4/api.cljc b/src/scicloj/kindly/v4/api.cljc index dce4b23..2882032 100644 --- a/src/scicloj/kindly/v4/api.cljc +++ b/src/scicloj/kindly/v4/api.cljc @@ -14,14 +14,12 @@ (defn deep-merge "Recursively merges maps only." [& xs] - (reduce (fn m [a b] - (if (and (or (nil? a) - (map? a)) - (or (nil? b) - (map? b))) - (merge-with m a b) - b)) - xs)) + (->> xs + (remove nil?) + (reduce (fn m [a b] + (if (and (map? a) (map? b)) + (merge-with m a b) + b))))) (defn get-options []