A trio of functions for combining hashmaps.
A trio of functions for combining hashmaps.
Speedily combine hashmaps m1 and m2 by merging exactly two 'levels'
deep. Top-level keys must be associated to hashmaps that themselves may be
merge-ed.
A more basic cousin of deep-merge.
Note:
Example:
(merge-merge {:a {:b 22} :c {:d 44}} {:a {:b 99} :e {:f 55}}) ;; => {:a {:b 99}, :c {:d 44}, :e {:f 55}}
Speedily combine hashmaps `m1` and `m2` by merging exactly two 'levels'
deep. Top-level keys *must* be associated to hashmaps that themselves may be
`merge`-ed.
A more basic cousin of [deep-merge](https://clojure.atlassian.net/issues?jql=textfields%20~%20%22deep-merge%22&selectedIssue=CLJ-1468).
Note:
1. Argument types are not checked to be valid arraymaps/hashmaps.
2. Metadata is not preserved.
3. Map type (i.e., sorted) is not guaranteed to be preserved.
Example:
```clojure
(merge-merge {:a {:b 22} :c {:d 44}} {:a {:b 99} :e {:f 55}}) ;; => {:a {:b 99}, :c {:d 44}, :e {:f 55}}
```Speedily combine hashmaps m1 and m2, similar to merge.
Note:
Example:
(smerge {:a 11 :b 999} {:b 22 :c 33}) ;; => {:a 11, :b 22, :c 33}
Speedily combine hashmaps `m1` and `m2`, similar to [merge](https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/merge).
Note:
1. Argument types are not checked to be valid arraymaps/hashmaps.
2. Metadata is not preserved.
3. Map type (i.e., sorted) is not guaranteed to be preserved.
Example:
```clojure
(smerge {:a 11 :b 999} {:b 22 :c 33}) ;; => {:a 11, :b 22, :c 33}
```Speedily combine hashmaps m1 and m2, using function f for overlapping
keys, similar to merge-with.
Note:
Example:
(smerge-with + {:a 11 :b 20} {:b 2 :c 33}) ;; => {:a 11, :b 22, :c 33}
Speedily combine hashmaps `m1` and `m2`, using function `f` for overlapping
keys, similar to [merge-with](https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/merge-with).
Note:
1. Argument types are not checked to be valid arraymaps/hashmaps.
2. Metadata is not preserved.
3. Map type (i.e., sorted) is not guaranteed to be preserved.
Example:
```clojure
(smerge-with + {:a 11 :b 20} {:b 2 :c 33}) ;; => {:a 11, :b 22, :c 33}
```cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |