smoosh.core

A trio of functions for combining hashmaps.

merge-merge

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:

  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:

(merge-merge {:a {:b 22} :c {:d 44}} {:a {:b 99} :e {:f 55}}) ;; => {:a {:b 99}, :c {:d 44}, :e {:f 55}}

smerge

Speedily combine hashmaps m1 and m2, similar to 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:

(smerge {:a 11 :b 999} {:b 22 :c 33}) ;; => {:a 11, :b 22, :c 33}

smerge-with

Speedily combine hashmaps m1 and m2, using function f for overlapping keys, similar to 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:

(smerge-with + {:a 11 :b 20} {:b 2 :c 33}) ;; => {:a 11, :b 22, :c 33}