Liking cljdoc? Tell your friends :D

plumbing.map

Common operations on maps (both Clojure immutable and mutable Java stuff)

Common operations on maps (both Clojure immutable and mutable Java stuff)
raw docstring

collateclj

(collate flat-counts)

Take a seq of [k v] counts and sum them up into a HashMap on k.

Take a seq of [k v] counts and sum them up into a HashMap on k.
sourceraw docstring

deep-collateclj

(deep-collate nested-counts)

Take a seq of [kseq v] counts and sum them up into nested HashMaps

Take a seq of [kseq v] counts and sum them up into nested HashMaps
sourceraw docstring

flattenclj/s

(flatten m)

Transform a nested map into a seq of [keyseq leaf-val] pairs

Transform a nested map into a seq of [keyseq leaf-val] pairs
sourceraw docstring

get!cljmacro

(get! m k default-expr)

Get the value in java.util.Map m under key k. If the key is not present, set the value to the result of default-expr and return it. Useful for constructing mutable nested structures on the fly.

(.add ^List (get! m :k (java.util.ArrayList.)) :foo)

Get the value in java.util.Map m under key k.  If the key is not present,
set the value to the result of default-expr and return it.  Useful for
constructing mutable nested structures on the fly.

(.add ^List (get! m :k (java.util.ArrayList.)) :foo)
sourceraw docstring

inc-key!clj

(inc-key! m k d)

Increment the value in java.util.Map m under key k by double d.

Increment the value in java.util.Map m under key k by double d.
sourceraw docstring

inc-key-in!clj

(inc-key-in! m ks d)

Increment the value in java.util.Map m under key-seq ks by double d, creating and storing HashMaps under missing keys on the path to this leaf.

Increment the value in java.util.Map m under key-seq ks by double d,
creating and storing HashMaps under missing keys on the path to this leaf.
sourceraw docstring

keep-leavesclj/s

(keep-leaves f m)

Takes a nested map and returns a nested map with the same shape, where each (non-map) leaf v is transformed to (f v), or removed if it returns nil. Empty maps produced by this pruning are themselves pruned from the output.

Takes a nested map and returns a nested map with the same shape, where each
(non-map) leaf v is transformed to (f v), or removed if it returns nil.
Empty maps produced by this pruning are themselves pruned from the output.
sourceraw docstring

keep-leaves-and-pathclj/s

(keep-leaves-and-path f m)
(keep-leaves-and-path f ks m)

Takes a nested map and returns a nested map with the same shape, where each (non-map) leaf v is transformed to (f key-seq v), or removed if it returns nil. key-seq is the sequence of keys to reach this leaf, starting at the root. Empty maps produced by this pruning are themselves pruned from the output.

Takes a nested map and returns a nested map with the same shape, where each
(non-map) leaf v is transformed to (f key-seq v), or removed if it returns nil.
key-seq is the sequence of keys to reach this leaf, starting at the root.
Empty maps produced by this pruning are themselves pruned from the output.
sourceraw docstring

keyword-mapclj/smacro

(keyword-map & syms)

Expands to a map whose keys are keywords with the same name as the given symbols, e.g.:

(let [x 41, y (inc x)] (keyword-map x y))

;; => {:x 41, :y 42}

Expands to a map whose keys are keywords with the same name as the given
symbols, e.g.:

  (let [x 41, y (inc x)]
    (keyword-map x y))

  ;; => {:x 41, :y 42}
sourceraw docstring

map-leavesclj/s

(map-leaves f m)

Takes a nested map and returns a nested map with the same shape, where each (non-map) leaf v is transformed to (f v).

Takes a nested map and returns a nested map with the same shape, where each
(non-map) leaf v is transformed to (f v).
sourceraw docstring

map-leaves-and-pathclj/s

(map-leaves-and-path f m)
(map-leaves-and-path f ks m)

Takes a nested map and returns a nested map with the same shape, where each (non-map) leaf v is transformed to (f key-seq v). key-seq is the sequence of keys to reach this leaf, starting at the root.

Takes a nested map and returns a nested map with the same shape, where each
(non-map) leaf v is transformed to (f key-seq v).
key-seq is the sequence of keys to reach this leaf, starting at the root.
sourceraw docstring

merge-disjointclj/s

(merge-disjoint)
(merge-disjoint m)
(merge-disjoint m1 m2)
(merge-disjoint m1 m2 & maps)

Like merge, but throws with any key overlap between maps

Like merge, but throws with any key overlap between maps
sourceraw docstring

merge-with-keyclj/s

(merge-with-key f & maps)

Like merge-with, but the merging function takes the key being merged as the first argument

Like merge-with, but the merging function takes the key being merged
as the first argument
sourceraw docstring

safe-select-keysclj/s

(safe-select-keys m ks)

Like select-keys, but asserts that all keys are present.

Like select-keys, but asserts that all keys are present.
sourceraw docstring

topological-sortclj/s≠

(topological-sort child-map & [include-leaves?])
clj

Take an adjacency list representation of a graph (a map from node names to sequences of child node names), and return a topological ordering of the node names in linear time, or throw an error if the graph is cyclic. If include-leaves? is false the ordering will only include keys from child-map, and if true it will also include nodes only named as children in child-map.

Take an adjacency list representation of a graph (a map from node names to
sequences of child node names), and return a topological ordering of the node
names in linear time, or throw an error if the graph is cyclic.
If include-leaves? is false the ordering will only include keys from child-map,
and if true it will also include nodes only named as children in child-map.
source (clj)source (cljs)raw docstring

unflattenclj/s

(unflatten s)

Transform a seq of [keyseq leaf-val] pairs into a nested map. If one keyseq is a prefix of another, you're on your own.

Transform a seq of [keyseq leaf-val] pairs into a nested map.
If one keyseq is a prefix of another, you're on your own.
sourceraw docstring

update-key!clj

(update-key! m k f)
(update-key! m k f & args)

Transform value in java.util.Map m under key k with fn f.

Transform value in java.util.Map m under key k with fn f.
sourceraw docstring

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

× close