(assoc-if m k v)
(assoc-if m k v & more)
assoc key/value pairs to the map only on non-nil values
(assoc-if {} :a 1) => {:a 1}
(assoc-if {} :a 1 :b nil) => {:a 1}
assoc key/value pairs to the map only on non-nil values (assoc-if {} :a 1) => {:a 1} (assoc-if {} :a 1 :b nil) => {:a 1}
(assoc-in-if m arr v)
assoc-in a nested key/value pair to a map only on non-nil values
(assoc-in-if {} [:a :b] 1) => {:a {:b 1}}
(assoc-in-if {} [:a :b] nil) => {}
assoc-in a nested key/value pair to a map only on non-nil values (assoc-in-if {} [:a :b] 1) => {:a {:b 1}} (assoc-in-if {} [:a :b] nil) => {}
(assoc-in-nil m ks v)
only assoc-in if the value in the original map is nil
(assoc-in-nil {} [:a :b] 2) => {:a {:b 2}}
(assoc-in-nil {:a {:b 1}} [:a :b] 2) => {:a {:b 1}}
only assoc-in if the value in the original map is nil (assoc-in-nil {} [:a :b] 2) => {:a {:b 2}} (assoc-in-nil {:a {:b 1}} [:a :b] 2) => {:a {:b 1}}
(assoc-nil m k v)
(assoc-nil m k v & more)
only assoc if the value in the original map is nil
(assoc-nil {:a 1} :b 2) => {:a 1 :b 2}
(assoc-nil {:a 1} :a 2 :b 2) => {:a 1 :b 2}
only assoc if the value in the original map is nil (assoc-nil {:a 1} :b 2) => {:a 1 :b 2} (assoc-nil {:a 1} :a 2 :b 2) => {:a 1 :b 2}
(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 {}}
(into-if to from)
like into but filters nil values for both key/value pairs and sequences
(into-if [] [1 nil 2 3]) => [1 2 3]
(into-if {:a 1} {:b nil :c 2}) => {:a 1 :c 2}
like into but filters nil values for both key/value pairs and sequences (into-if [] [1 nil 2 3]) => [1 2 3] (into-if {:a 1} {:b nil :c 2}) => {:a 1 :c 2}
(merge-if)
(merge-if m)
(merge-if m1 m2)
(merge-if m1 m2 & more)
merges key/value pairs into a single map only if the value exists
(merge-if {:a nil :b 1}) => {:b 1}
(merge-if {:a 1} {:b nil :c 2}) => {:a 1 :c 2}
(merge-if {:a 1} {:b nil} {:c 2}) => {:a 1 :c 2}
merges key/value pairs into a single map only if the value exists (merge-if {:a nil :b 1}) => {:b 1} (merge-if {:a 1} {:b nil :c 2}) => {:a 1 :c 2} (merge-if {:a 1} {:b nil} {:c 2}) => {:a 1 :c 2}
(merge-nil)
(merge-nil m)
(merge-nil m1 m2)
(merge-nil m1 m2 & more)
only merge if the value in the original map is nil
(merge-nil {:a 1} {:b 2}) => {:a 1 :b 2}
(merge-nil {:a 1} {:a 2}) => {:a 1}
only merge if the value in the original map is nil (merge-nil {:a 1} {:b 2}) => {:a 1 :b 2} (merge-nil {:a 1} {:a 2}) => {:a 1}
(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}
(select-keys-if m ks)
selects only the non-nil key/value pairs from a map
(select-keys-if {:a 1 :b nil} [:a :b]) => {:a 1}
(select-keys-if {: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-if {:a 1 :b nil} [:a :b]) => {:a 1} (select-keys-if {:a 1 :b nil :c 2} [:a :b :c]) => {:a 1 :c 2}
(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}}
(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
(update-in-if m arr f & args)
update-in a nested key/value pair only if the value exists
(update-in-if {:a {:b 1}} [:a :b] inc) => {:a {:b 2}}
(update-in-if {} [:a :b] inc) => {}
update-in a nested key/value pair only if the value exists (update-in-if {:a {:b 1}} [:a :b] inc) => {:a {:b 2}} (update-in-if {} [:a :b] inc) => {}
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close