Utility for map data structure
Utility for map data structure
(add-ids m)
Add the key to all map values (which are expected to be maps).
Add the key to all map values (which are expected to be maps).
(apply-to-keys maps f & ks)
Apply function f
to each key in ks
in the maps in maps
Params:
f
fn with three arguments. First is k
the key currently update (one of ks
), second is m
the current value of the m while it is updated, third is v
the current value of key k
in map m
maps
is a sequence of mapks
keys in the map to apply f
toApply function `f` to each key in `ks` in the maps in `maps` Params: * `f` fn with three arguments. First is `k` the key currently update (one of `ks`), second is `m` the current value of the m while it is updated, third is `v` the current value of key `k` in map `m` * `maps` is a sequence of map * `ks` keys in the map to apply `f` to
(deep-merge & maps)
Deep merge nested maps. Last map has higher priority
This code comes from this gist
Deep merge nested maps. Last map has higher priority This code comes from this [gist](https://gist.github.com/danielpcox/c70a8aa2c36766200a95)
(idx-of v value)
Return the index of the first found value in the sequence
Return the index of the first found value in the sequence
(idx-of-pred v pred)
Same as idx-of but with a predicate
Same as idx-of but with a predicate
(keys->sequence-number m)
Return a map associating a key of the map m
with a number, numbered from 1 to n.
Return a map associating a key of the map `m` with a number, numbered from 1 to n.
(map-difference m1 m2)
(map-util-hashmappify-vals m modify-type-fn)
Converts an ordinary Clojure map into a Clojure map with nested map values recursively translated into what modify-type-fn is returning. Based on walk/stringify-keys. When key or value is nil, the pair is removed, as the hashmap doesn't allow null keys/values.
Converts an ordinary Clojure map into a Clojure map with nested map values recursively translated into what modify-type-fn is returning. Based on walk/stringify-keys. When key or value is nil, the pair is removed, as the hashmap doesn't allow null keys/values.
(prefixify-children thing)
(prefixify-map prefix thing)
(prefixify-vec prefix thing)
(remove-nil-submap-vals m)
(remove-nil-vals m)
(replace-keys m1 m2)
Replace keys in m2
with keys from m1
. Similiar to merge but non-existen keys in first map won't be added. e.g. (replace-keys {:a 3 :b 2} {:a 1}) -> {:a 3}
Replace keys in `m2` with keys from `m1`. Similiar to merge but non-existen keys in first map won't be added. e.g. (replace-keys {:a 3 :b 2} {:a 1}) -> {:a 3}
(translate-keys m translation)
Translate keys of map m
thanks to the translation
.
Translate keys of map `m` thanks to the `translation`.
(translate-vals m translation)
Translate vals of map m
thanks to the translation
.
Translate vals of map `m` thanks to the `translation`.
(update-kw m kws f)
Update the keywords kws
in map m
with function f
Update the keywords `kws` in map `m` with function `f`
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close