Liking cljdoc? Tell your friends :D

clodash.map

Functions that operate on Clojure maps.

Functions that operate on Clojure maps.
raw docstring

assoc-if-not-blankclj


assoc-if-not-nilclj


assoc-if-not-presentclj


assoc-in-if-presentclj

(assoc-in-if-present m path f)

Assocs f into m only if the path presents in m

Assocs f into m only if the path presents in m
raw docstring

assoc-thunk-result-if-not-presentclj

(assoc-thunk-result-if-not-present m k thunk)
(assoc-thunk-result-if-not-present m k thunk & kvs)

Like assoc, except only adds the key-value pair if the key doesn't exist in the map

Like assoc, except only adds the key-value pair if the key doesn't exist in
the map
raw docstring

contains-path?clj

(contains-path? m path)

Whether the specified path exists in the map

Whether the specified path exists in the map
raw docstring

copy-keyclj

(copy-key m from-k to-k)

deep-merge-withclj

(deep-merge-with f & maps)

Like merge-with, but merges maps recursively, applying the given fn only when there's a non-map at a particular level.

(deep-merge-with + {:a {:b {:c 1 :d {:x 1 :y 2}} :e 3} :f 4} {:a {:b {:c 2 :d {:z 9} :z 3} :e 100}}) -> {:a {:b {:z 3, :c 3, :d {:z 9, :x 1, :y 2}}, :e 103}, :f 4}

Like merge-with, but merges maps recursively, applying the given fn
only when there's a non-map at a particular level.

(deep-merge-with + {:a {:b {:c 1 :d {:x 1 :y 2}} :e 3} :f 4}
                   {:a {:b {:c 2 :d {:z 9} :z 3} :e 100}})
-> {:a {:b {:z 3, :c 3, :d {:z 9, :x 1, :y 2}}, :e 103}, :f 4}
raw docstring

dissoc-inclj

(dissoc-in m [k & ks :as path])
(dissoc-in m path & more-paths)

Dissociates an entry from a nested associative structure returning a new nested structure. path is a sequence of keys. Any empty maps that result will not be present in the new structure.

Dissociates an entry from a nested associative structure returning a new
nested structure. path is a sequence of keys. Any empty maps that result
will not be present in the new structure.
raw docstring

dissoc-or-throwclj

(dissoc-or-throw m & ks)

filter-by-keyclj

(filter-by-key pred m)

Given a predicate like (fn [k] ...) returns a map with only entries with keys that match it.

Given a predicate like (fn [k] ...) returns a map with only entries with keys
that match it.
raw docstring

filter-by-valclj

(filter-by-val pred m)

Given a predicate like (fn [v] ...) returns a map with only entries with vals that match it.

Given a predicate like (fn [v] ...) returns a map with only entries with vals
that match it.
raw docstring

filter-mapclj

(filter-map pred m)

Given a predicate like (fn [k v] ...) returns a map with only entries that match it.

Given a predicate like (fn [k v] ...) returns a map with only entries that
match it.
raw docstring

for-mapcljmacro

(for-map seq-exprs key-expr val-expr)
(for-map m-sym seq-exprs key-expr val-expr)

Like 'for' for building maps. Same bindings except the body should have a key-expression and value-expression. If a key is repeated, the last value (according to "for" semantics) will be retained. (= (for-map [i (range 2) j (range 2)] [i j] (even? (+ i j))) {[0 0] true, [0 1] false, [1 0] false, [1 1] true}) An optional symbol can be passed as a first argument, which will be bound to the transient map containing the entries produced so far.

Like 'for' for building maps. Same bindings except the body should have a
key-expression and value-expression. If a key is repeated, the last
value (according to "for" semantics) will be retained.
(= (for-map [i (range 2) j (range 2)] [i j] (even? (+ i j)))
   {[0 0] true, [0 1] false, [1 0] false, [1 1] true})
An optional symbol can be passed as a first argument, which will be
bound to the transient map containing the entries produced so far.
raw docstring

invert-mapclj

(invert-map m)

Inverts a map: key becomes value, value becomes key

Inverts a map: key becomes value, value becomes key
raw docstring

keys-to-keywordsclj

(keys-to-keywords m
                  &
                  {:keys [underscore-to-hyphens?]
                   :or {underscore-to-hyphens? true}})

Recursively transform the key of the map(could be nested) to be type of keyword

Recursively transform the key of the map(could be nested) to be type of keyword
raw docstring

keywords->hyphenated-keywordsclj

(keywords->hyphenated-keywords m)

Transforms the keywords in map to hyphen seperated style

Transforms the keywords in map to hyphen seperated style
raw docstring

keywords->underscored-keywordsclj

(keywords->underscored-keywords m)

Transforms the keywords in map to underscore seperated style

Transforms the keywords in map to underscore seperated style
raw docstring

keywords->underscored-stringsclj

(keywords->underscored-strings m)

Transforms the keywords in map to be underscored strings

Transforms the keywords in map to be underscored strings
raw docstring

let-mapcljmacro

(let-map & kvs)

Creates a hash-map which can refer to the symbols of the names of the keys declared above.

Creates a hash-map which can refer to the symbols of the names of the keys
declared above.
raw docstring

map-differenceclj

(map-difference m1 m2)

Returns the difference of m1 and m2: the entires in m1 but not in m2 + entries in m2 but not in m1

Returns the difference of m1 and m2: the entires in m1 but not in m2 +
entries in m2 but not in m1
raw docstring

map-keysclj

(map-keys f m)

Build map (f k) -> v for [k v] in map m

Build map (f k) -> v for [k v] in map m
raw docstring

map-over-mapclj

(map-over-map f m)

Given a function like (fn [k v] ...) returns a new map with each entry mapped by it.

Given a function like (fn [k v] ...) returns a new map with each entry mapped
by it.
raw docstring

map-valuesclj

(map-values f m)

Build map k -> (f v) for [k v] in map, preserving the initial type

Build map k -> (f v) for [k v] in map, preserving the initial type
raw docstring

move-keyclj

(move-key m old-key new-key)

Changes the entry's key which is old-key to new-key (the corresponding value untouched)

Changes the entry's key which is old-key to new-key (the corresponding value
untouched)
raw docstring

nested-dissocclj

(nested-dissoc data & ks)

dissoc keys from every map at every level of a nested data structure

dissoc keys from every map at every level of a nested data structure
raw docstring

pathsclj

(paths m)

Return the paths of the leaves in the map

Return the paths of the leaves in the map
raw docstring

rand-select-keysclj

(rand-select-keys m n)

Selects a subset of 'n' k/v pairs from 'm'

Selects a subset of 'n' k/v pairs from 'm'
raw docstring

recursive-mergeclj


rmergeclj

(rmerge & maps)

Recursive merge of the provided maps.

Recursive merge of the provided maps.
raw docstring

select-keys-alwaysclj

(select-keys-always m ks)
(select-keys-always m ks default)

Selects the entires whose key presents in ks from m

Selects the entires whose key presents in ks from m 
raw docstring

select-pathsclj

(select-paths m & paths)

Similar to select-keys, just the 'key' here is a path in the nested map

Similar to select-keys, just the 'key' here is a path in the nested map
raw docstring

sgetclj

(sget m k)

Safe get. Get the value of key k from map m only if the key really exists, throw exception otherwise.

Safe get. Get the value of key `k` from map `m` only if the key really
exists, throw exception otherwise.
raw docstring

sorted-zipmapclj

(sorted-zipmap keys vals)

Returns a sorted map with the keys mapped to the corresponding vals.

Returns a sorted map with the keys mapped to the corresponding vals.
raw docstring

submap?clj

(submap? sub-map m)

Determine whether sub-map is a submap of m.

Determine whether sub-map is a submap of m.
raw docstring

subpath?clj

(subpath? root-path path)

true if 'path' is a child of 'root-path'

true if 'path' is a child of 'root-path'
raw docstring

subpathsclj

(subpaths path)

transform-keywordsclj

(transform-keywords f m)

Transforms all the keywords in the specified map using the speicified function

Transforms all the keywords in the specified map using the speicified function
raw docstring

update-in-if-presentclj

(update-in-if-present m path f)

Updates the specified path in the map only if it presents

Updates the specified path in the map only if it presents
raw docstring

update-in-matchingclj

(update-in-matching m path f)
(update-in-matching m path f a1)
(update-in-matching m path f a1 a2)
(update-in-matching m path f a1 a2 a3)
(update-in-matching m path f a1 a2 a3 & args)

update-in that accept :, :-val

(update-in-matching {:foo {:bar {:baz [1]} :quz {:baz [2]}}} [:foo :-val :baz :] inc) => {:foo {:bar {:baz [2]}, :quz {:baz [3]}}}

update-in that accept :*, :*-val

(update-in-matching
  {:foo {:bar {:baz [1]} :quz {:baz [2]}}}
  [:foo :*-val :baz :*]
  inc) => {:foo {:bar {:baz [2]}, :quz {:baz [3]}}} 
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close