Liking cljdoc? Tell your friends :D

hara.data.base.tree


contains-ns-key?clj

(contains-ns-key? fm ns)

Returns true if any key in map contains a namespace value

(contains-ns-key? {:hello/a 1 :hello/b 2 :there/a 3 :there/b 4} :hello) => true

Returns `true` if any key in map contains a namespace value

(contains-ns-key? {:hello/a 1 :hello/b 2
                   :there/a 3 :there/b 4} :hello)
=> true
raw docstring

flatten-keysclj

(flatten-keys m)

takes map m and flattens the first nested layer onto the root layer.

(flatten-keys {:a {:b 2 :c 3} :e 4}) => {:a/b 2 :a/c 3 :e 4}

(flatten-keys {:a {:b {:c 3 :d 4} :e {:f 5 :g 6}} :h {:i 7} :j 8}) => {:a/b {:c 3 :d 4} :a/e {:f 5 :g 6} :h/i 7 :j 8}

takes map `m` and flattens the first nested layer onto the root layer.

(flatten-keys {:a {:b 2 :c 3} :e 4})
=> {:a/b 2 :a/c 3 :e 4}

(flatten-keys {:a {:b {:c 3 :d 4}
                   :e {:f 5 :g 6}}
               :h {:i 7}
               :j 8})
=> {:a/b {:c 3 :d 4} :a/e {:f 5 :g 6} :h/i 7 :j 8}
raw docstring

flatten-keys-nestedclj

(flatten-keys-nested m)
(flatten-keys-nested m max keep-empty)
(flatten-keys-nested m max keep-empty seperator)

Returns a single associative map with all of the nested keys of m flattened. If keep is added, it preserves all the empty sets

(flatten-keys-nested {"a" {"b" {"c" 3 "d" 4} "e" {"f" 5 "g" 6}} "h" {"i" {}}}) => {"a/b/c" 3 "a/b/d" 4 "a/e/f" 5 "a/e/g" 6}

(flatten-keys-nested {"a" {"b" {"c" 3 "d" 4} "e" {"f" 5 "g" 6}} "h" {"i" {}}} -1 true) => {"a/b/c" 3 "a/b/d" 4 "a/e/f" 5 "a/e/g" 6 "h/i" {}}

Returns a single associative map with all of the nested
 keys of `m` flattened. If `keep` is added, it preserves all the
 empty sets

(flatten-keys-nested {"a" {"b" {"c" 3 "d" 4}
                           "e" {"f" 5 "g" 6}}
                      "h" {"i" {}}})
=> {"a/b/c" 3 "a/b/d" 4 "a/e/f" 5 "a/e/g" 6}

(flatten-keys-nested {"a" {"b" {"c" 3 "d" 4}
                           "e" {"f" 5 "g" 6}}
                      "h" {"i" {}}}
                     -1 true)
=> {"a/b/c" 3 "a/b/d" 4 "a/e/f" 5 "a/e/g" 6 "h/i" {}}
raw docstring

group-by-setclj

(group-by-set f coll)

Returns a map of the elements of coll keyed by the result of f on each element. The value at each key will be a set of the corresponding elements, in the order they appeared in coll.

(group-by-set even? [1 2 3 4 5]) => {false #{1 3 5}, true #{2 4}}

Returns a map of the elements of coll keyed by the result of
f on each element. The value at each key will be a set of the
corresponding elements, in the order they appeared in coll.

(group-by-set even? [1 2 3 4 5])
=> {false #{1 3 5}, true #{2 4}}
raw docstring

group-keysclj

(group-keys fm)
(group-keys fm ns)

Returns the set of keys in fm that has keyword namespace of ns (group-keys {:hello/a 1 :hello/b 2 :there/a 3 :there/b 4}) => {:there #{:there/a :there/b}, :hello #{:hello/b :hello/a}}

(group-keys {:hello/a 1 :hello/b 2 :there/a 3 :there/b 4} :hello) => #{:hello/a :hello/b}

Returns the set of keys in `fm` that has keyword namespace
of `ns`
(group-keys {:hello/a 1 :hello/b 2
             :there/a 3 :there/b 4})
=> {:there #{:there/a :there/b}, :hello #{:hello/b :hello/a}}

(group-keys {:hello/a 1 :hello/b 2
             :there/a 3 :there/b 4} :hello)
=> #{:hello/a :hello/b}
raw docstring

list-ns-keysclj

(list-ns-keys fm)

Returns the set of keyword namespaces within a map

(list-ns-keys {:hello/a 1 :hello/b 2 :there/a 3 :there/b 4}) => #{:hello :there}

Returns the set of keyword namespaces within a map

(list-ns-keys {:hello/a 1 :hello/b 2
               :there/a 3 :there/b 4})
=> #{:hello :there}
raw docstring

nest-keysclj

(nest-keys m nskv)
(nest-keys m nskv ex)

Returns a map that takes m and extends all keys with the nskv vector. ex is the list of keys that are not extended.

(nest-keys {:a 1 :b 2} [:hello :there]) => {:hello {:there {:a 1 :b 2}}}

(nest-keys {:there 1 :b 2} [:hello] [:there]) => {:hello {:b 2} :there 1}

Returns a map that takes `m` and extends all keys with the
`nskv` vector. `ex` is the list of keys that are not extended.

(nest-keys {:a 1 :b 2} [:hello :there])
=> {:hello {:there {:a 1 :b 2}}}

(nest-keys {:there 1 :b 2} [:hello] [:there])
=> {:hello {:b 2} :there 1}
raw docstring

pathify-keys-nestedclj

(pathify-keys-nested m)
(pathify-keys-nested m max)
(pathify-keys-nested m max keep-empty)
(pathify-keys-nested m max keep-empty arr)

converts a nested map structure into a flat map structure

(pathify-keys-nested {:a {:b {:c 1}}}) => {[:a :b :c] 1}

(pathify-keys-nested {:a {:b {:c 1}}} 2) => {[:a :b] {:c 1}}

(pathify-keys-nested {:a {:b {:c 1 :d 3 :e {}}}} -1 true) => {[:a :b :c] 1, [:a :b :d] 3, [:a :b :e] {}}

converts a nested map structure into a flat map structure

(pathify-keys-nested {:a {:b {:c 1}}})
=> {[:a :b :c] 1}

(pathify-keys-nested {:a {:b {:c 1}}} 2)
=> {[:a :b] {:c 1}}

(pathify-keys-nested {:a {:b {:c 1
                              :d 3
                              :e {}}}}
                     -1 true)
=> {[:a :b :c] 1, [:a :b :d] 3, [:a :b :e] {}}
raw docstring

treeify-keysclj

(treeify-keys m)

Returns a nested map, expanding out the first level of keys into additional hash-maps.

(treeify-keys {:a/b 2 :a/c 3}) => {:a {:b 2 :c 3}}

(treeify-keys {:a/b {:e/f 1} :a/c {:g/h 1}}) => {:a {:b {:e/f 1} :c {:g/h 1}}}

Returns a nested map, expanding out the first
 level of keys into additional hash-maps.

(treeify-keys {:a/b 2 :a/c 3})
=> {:a {:b 2 :c 3}}

(treeify-keys {:a/b {:e/f 1} :a/c {:g/h 1}})
=> {:a {:b {:e/f 1}
        :c {:g/h 1}}}
raw docstring

treeify-keys-nestedclj

(treeify-keys-nested m)

Returns a nested map, expanding out all levels of keys into additional hash-maps.

(treeify-keys-nested {:a/b 2 :a/c 3}) => {:a {:b 2 :c 3}}

(treeify-keys-nested {:a/b {:e/f 1} :a/c {:g/h 1}}) => {:a {:b {:e {:f 1}} :c {:g {:h 1}}}}

Returns a nested map, expanding out all
levels of keys into additional hash-maps.

 (treeify-keys-nested {:a/b 2 :a/c 3})
 => {:a {:b 2 :c 3}}

 (treeify-keys-nested {:a/b {:e/f 1} :a/c {:g/h 1}})
 => {:a {:b {:e {:f 1}}
         :c {:g {:h 1}}}}
raw docstring

unnest-keysclj

(unnest-keys m nskv)
(unnest-keys m nskv ex)

The reverse of nest-keys. Takes m and returns a map with all keys with a keyword-nsvec of nskv being 'unnested'

(unnest-keys {:hello/a 1 :hello/b 2 :there/a 3 :there/b 4} [:hello]) => {:a 1 :b 2 :there {:a 3 :b 4}}

(unnest-keys {:hello {:there {:a 1 :b 2}} :again {:c 3 :d 4}} [:hello :there] [:+]) => {:a 1 :b 2 :+ {:again {:c 3 :d 4}}}

The reverse of `nest-keys`. Takes `m` and returns a map
with all keys with a `keyword-nsvec` of `nskv` being 'unnested'

(unnest-keys {:hello/a 1
              :hello/b 2
              :there/a 3
              :there/b 4} [:hello])
=> {:a 1 :b 2
    :there {:a 3 :b 4}}

(unnest-keys {:hello {:there {:a 1 :b 2}}
              :again {:c 3 :d 4}} [:hello :there] [:+])
=> {:a 1 :b 2
    :+ {:again {:c 3 :d 4}}}
raw docstring

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

× close