Liking cljdoc? Tell your friends :D

hara.data.base.map


assoc-in-newclj

(assoc-in-new m ks v)

only assoc-in if the value in the original map is nil

(assoc-in-new {} [:a :b] 2) => {:a {:b 2}}

(assoc-in-new {:a {:b 1}} [:a :b] 2) => {:a {:b 1}}

only assoc-in if the value in the original map is nil

(assoc-in-new {} [:a :b] 2)
=> {:a {:b 2}}

(assoc-in-new {:a {:b 1}} [:a :b] 2)
=> {:a {:b 1}}
raw docstring

assoc-in-nnilclj

(assoc-in-nnil m arr v)

assoc-in a nested key/value pair to a map only on non-nil values

(assoc-in-nnil {} [:a :b] 1) => {:a {:b 1}}

(assoc-in-nnil {} [:a :b] nil) => {}

assoc-in a nested key/value pair to a map only on non-nil values

(assoc-in-nnil {} [:a :b] 1)
=> {:a {:b 1}}

(assoc-in-nnil {} [:a :b] nil)
=> {}
raw docstring

assoc-newclj

(assoc-new m k v)
(assoc-new m k v & more)

only assoc if the value in the original map is nil

(assoc-new {:a 1} :b 2) => {:a 1 :b 2}

(assoc-new {:a 1} :a 2 :b 2) => {:a 1 :b 2}

only assoc if the value in the original map is nil

(assoc-new {:a 1} :b 2)
=> {:a 1 :b 2}

(assoc-new {:a 1} :a 2 :b 2)
=> {:a 1 :b 2}
raw docstring

assoc-nnilclj

(assoc-nnil m k v)
(assoc-nnil m k v & more)

assoc key/value pairs to the map only on non-nil values

(assoc-nnil {} :a 1) => {:a 1}

(assoc-nnil {} :a 1 :b nil) => {:a 1}

assoc key/value pairs to the map only on non-nil values

(assoc-nnil {} :a 1)
=> {:a 1}

(assoc-nnil {} :a 1 :b nil)
=> {:a 1}
raw docstring

dissoc-inclj

(dissoc-in m [k & ks])
(dissoc-in m [k & ks] keep)

disassociates keys from a nested map. Setting keep to true will not remove a empty map after dissoc

(dissoc-in {:a {:b 10 :c 20}} [:a :b]) => {:a {:c 20}}

(dissoc-in {:a {:b 10}} [:a :b]) => {}

(dissoc-in {:a {:b 10}} [:a :b] true) => {:a {}}

disassociates keys from a nested map. Setting `keep` to `true` will
not remove a empty map after dissoc

(dissoc-in {:a {:b 10 :c 20}} [:a :b])
=> {:a {:c 20}}

(dissoc-in {:a {:b 10}} [:a :b])
=> {}

(dissoc-in {:a {:b 10}} [:a :b] true)
=> {:a {}}
raw docstring

filter-keysclj

(filter-keys pred m)

filters map based upon map keys

(filter-keys even? {0 :a 1 :b 2 :c}) => {0 :a, 2 :c}

filters map based upon map keys

(filter-keys even? {0 :a 1 :b 2 :c})
=> {0 :a, 2 :c}
raw docstring

filter-valsclj

(filter-vals pred m)

filters map based upon map values

(filter-vals even? {:a 1 :b 2 :c 3}) => {:b 2}

filters map based upon map values

(filter-vals even? {:a 1 :b 2 :c 3})
=> {:b 2}
raw docstring

into-nnilclj

(into-nnil to from)

like into but filters nil values for both key/value pairs and sequences

(into-nnil [] [1 nil 2 3]) => [1 2 3]

(into-nnil {:a 1} {:b nil :c 2}) => {:a 1 :c 2}

like into but filters nil values for both key/value pairs
and sequences

(into-nnil [] [1 nil 2 3])
=> [1 2 3]

(into-nnil {:a 1} {:b nil :c 2})
=> {:a 1 :c 2}
raw docstring

map-entriesclj

(map-entries f m)

manipulates a map given the function

(map-entries (fn [[k v]] [(keyword (str v)) (name k)]) {:a 1 :b 2 :c 3}) => {:1 "a", :2 "b", :3 "c"}

manipulates a map given the function

(map-entries (fn [[k v]]
               [(keyword (str v)) (name k)])
             {:a 1 :b 2 :c 3})
=> {:1 "a", :2 "b", :3 "c"}
raw docstring

map-keysclj

(map-keys f m)

changes the keys of a map

(map-keys inc {0 :a 1 :b 2 :c}) => {1 :a, 2 :b, 3 :c}

changes the keys of a map

(map-keys inc {0 :a 1 :b 2 :c})
=> {1 :a, 2 :b, 3 :c}
raw docstring

map-valsclj

(map-vals f m)

changes the values of a map

(map-vals inc {:a 1 :b 2 :c 3}) => {:a 2, :b 3, :c 4}

changes the values of a map

(map-vals inc {:a 1 :b 2 :c 3})
=> {:a 2, :b 3, :c 4}
raw docstring

merge-newclj

(merge-new)
(merge-new m)
(merge-new m1 m2)
(merge-new m1 m2 & more)

only merge if the value in the original map is nil

(merge-new {:a 1} {:b 2}) => {:a 1 :b 2}

(merge-new {:a 1} {:a 2}) => {:a 1}

only merge if the value in the original map is nil

(merge-new {:a 1} {:b 2})
=> {:a 1 :b 2}

(merge-new {:a 1} {:a 2})
=> {:a 1}
raw docstring

merge-nnilclj

(merge-nnil)
(merge-nnil m)
(merge-nnil m1 m2)
(merge-nnil m1 m2 & more)

merges key/value pairs into a single map only if the value exists

(merge-nnil {:a nil :b 1}) => {:b 1}

(merge-nnil {:a 1} {:b nil :c 2}) => {:a 1 :c 2}

(merge-nnil {:a 1} {:b nil} {:c 2}) => {:a 1 :c 2}

merges key/value pairs into a single map only if the value exists

(merge-nnil {:a nil :b 1})
=> {:b 1}

(merge-nnil {:a 1} {:b nil :c 2})
=> {:a 1 :c 2}

(merge-nnil {:a 1} {:b nil} {:c 2})
=> {:a 1 :c 2}
raw docstring

retract-inclj

(retract-in m rels)

reversed the changes by transform-in

(retract-in {:b 2, :c {:d 1}} {[:c :d] [:a]}) => {:a 1 :b 2}

reversed the changes by transform-in

(retract-in {:b 2, :c {:d 1}}
            {[:c :d] [:a]})
=> {:a 1 :b 2}
raw docstring

select-keys-nnilclj

(select-keys-nnil m ks)

selects only the non-nil key/value pairs from a map

(select-keys-nnil {:a 1 :b nil} [:a :b]) => {:a 1}

(select-keys-nnil {:a 1 :b nil :c 2} [:a :b :c]) => {:a 1 :c 2}

selects only the non-nil key/value pairs from a map

(select-keys-nnil {:a 1 :b nil} [:a :b])
=> {:a 1}

(select-keys-nnil {:a 1 :b nil :c 2} [:a :b :c])
=> {:a 1 :c 2}
raw docstring

transform-inclj

(transform-in m rels)

moves values around in a map according to a table

(transform-in {:a 1 :b 2} {[:c :d] [:a]}) => {:b 2, :c {:d 1}}

moves values around in a map according to a table

(transform-in {:a 1 :b 2}
              {[:c :d] [:a]})
=> {:b 2, :c {:d 1}}
raw docstring

transposeclj

(transpose m)

sets the vals and keys and vice-versa

(transpose {:a 1 :b 2 :c 3}) => {1 :a, 2 :b, 3 :c}

sets the vals and keys and vice-versa

(transpose {:a 1 :b 2 :c 3})
=> {1 :a, 2 :b, 3 :c}
raw docstring

uniqueclj

(unique m1 m2)

returns a map of all key/value pairs that differ from a second map

(unique {:a 1} {:a 2}) => {:a 1}

(unique {:a 1 :b 2} {:b 2}) => {:a 1}

(unique {:b 2} {:b 2 :a 1}) => nil

returns a map of all key/value pairs that differ from a second map

(unique {:a 1} {:a 2})
=> {:a 1}

(unique {:a 1 :b 2} {:b 2})
=> {:a 1}

(unique {:b 2} {:b 2 :a 1})
=> nil
raw docstring

update-in-nnilclj

(update-in-nnil m arr f & args)

update-in a nested key/value pair only if the value exists

(update-in-nnil {:a {:b 1}} [:a :b] inc) => {:a {:b 2}}

(update-in-nnil {} [:a :b] inc) => {}

update-in a nested key/value pair only if the value exists

(update-in-nnil {:a {:b 1}} [:a :b] inc)
=> {:a {:b 2}}

(update-in-nnil {} [:a :b] inc)
=> {}
raw docstring

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

× close