Added function for merging default board-config with custom parts
Very important in the future. Needs mega testing, I even started writing tests because of this.
This commit is contained in:
parent
e230e33a55
commit
bb02765233
1 changed files with 12 additions and 0 deletions
|
@ -9,6 +9,18 @@
|
||||||
[pred coll]
|
[pred coll]
|
||||||
(keep-indexed #(when (pred %2) %1) coll))
|
(keep-indexed #(when (pred %2) %1) coll))
|
||||||
|
|
||||||
|
(defn map-deep-merge-missing
|
||||||
|
"Merges two maps but only keys missing from first map"
|
||||||
|
[m1 m2]
|
||||||
|
(into m1
|
||||||
|
(for [k (keys m2)]
|
||||||
|
(let [val1 (get m1 k)
|
||||||
|
val2 (get m2 k)]
|
||||||
|
(if (and (map? val1)
|
||||||
|
(map? val2))
|
||||||
|
{k (map-deep-merge-missing val1 val2)}
|
||||||
|
{k (nil?-else val2 val1)})))))
|
||||||
|
|
||||||
;; ===== Macros =====
|
;; ===== Macros =====
|
||||||
(defmacro nil?-else
|
(defmacro nil?-else
|
||||||
"Return x unless it's nil, the return y"
|
"Return x unless it's nil, the return y"
|
||||||
|
|
Loading…
Reference in a new issue