Macros and functions for handling nil under various circumstances.
Macros and functions for handling nil under various circumstances.
(alt)
(alt x)
(alt x & xs)
Selects the first non-nil value.
Being a macro, arguments are not evaluated until needed.
Ex. (alt nil false 42) => false
Selects the first non-nil value. Being a macro, arguments are not evaluated until needed. Ex. (alt nil false 42) => false
(assoc hmap k v)
(assoc hmap k v & kvs)
Behaves like standard assoc
but associates v
only if it is not nil.
Behaves like standard `assoc` but associates `v` only if it is not nil.
(assoc-in hmap path v)
Behaves like standard assoc-in
but associates v
only if it is not nil.
Behaves like standard `assoc-in` but associates `v` only if it is not nil.
(assoc-strict hmap k v)
(assoc-strict hmap k v & kvs)
If v
is nil, not only is it not associated, the involved key is actually removed from the map.
If `v` is nil, not only is it not associated, the involved key is actually removed from the map.
(call f & args)
Calls f
with the given arguments only if f
is not nil.
Being a macro, the arguments are not evaluated if there are not needed.
Calls `f` with the given arguments only if `f` is not nil. Being a macro, the arguments are not evaluated if there are not needed.
(dissoc-in hmap path)
Deep dissoc, natural counterpart of Clojure's assoc-in
.
It is recursive, meaning that if dissociating a key results in an empty map, that map is itself removed from its parent (provided it is of course nested).
Eg. (dissoc-in {:a {:b 42} :c :ok} [:a :b])
=> {:c :ok}
Deep dissoc, natural counterpart of Clojure's `assoc-in`. It is recursive, meaning that if dissociating a key results in an empty map, that map is itself removed from its parent (provided it is of course nested). Eg. (dissoc-in {:a {:b 42} :c :ok} [:a :b]) => {:c :ok}
(dmerge & hmaps)
Deep merges the given maps.
Merging a key pointing to nil results in that key being dissociated. Similarly to dissoc-in
, empty maps are recursively
removed.
Eg. (dmerge {:a {:b 42}} {:a {:b nil} :c 42})
=> {:c 42}
Deep merges the given maps. Merging a key pointing to nil results in that key being dissociated. Similarly to `dissoc-in`, empty maps are recursively removed. Eg. (dmerge {:a {:b 42}} {:a {:b nil} :c 42}) => {:c 42}
(dmerge-with f & hmaps)
Is to dmerge
what this namespace's version of merge-with
is to merge
.
Is to `dmerge` what this namespace's version of `merge-with` is to `merge`.
(dmerge-with* f hmaps)
(dmerge-with* f hmap-1 hmap-2)
Like dmerge-with
, but maps are provided in a collection.
Like `dmerge-with`, but maps are provided in a collection.
(merge & hmaps)
Just like standard merge
, but a key pointing to nil in the right map means it must be dissociated.
Eg. (merge {:a 42 :b 42} {:b nil :c 42})
=> {:a 42
:c 42}
Just like standard `merge`, but a key pointing to nil in the right map means it must be dissociated. Eg. (merge {:a 42 :b 42} {:b nil :c 42}) => {:a 42 :c 42}
(merge-with f & hmaps)
Just like standard 'merge-with' but behaves like this namespace's version of merge
: a key pointing to a nil value in a
right map means it will be dissociated. The same applies when f
returns nil.
Just like standard 'merge-with' but behaves like this namespace's version of `merge`: a key pointing to a nil value in a right map means it will be dissociated. The same applies when `f` returns nil.
(merge-with* f hmaps)
Just like this namespace's version of merge-with
but maps are provided in a collection.
Just like this namespace's version of `merge-with` but maps are provided in a collection.
(no-op)
(no-op _)
(no-op _ _)
(no-op _ _ _)
(no-op _ _ _ _)
(no-op _ _ _ _ _)
(no-op _ _ _ _ _ _)
(no-op _ _ _ _ _ _ _)
(no-op _ _ _ _ _ _ _ _)
(no-op _ _ _ _ _ _ _ _ & _)
Does absolutely nothing, but efficiently.
Does absolutely nothing, but efficiently.
(prune node)
If node is a map, keys with nil values will be removed. In case of nested maps, the process is recursive.
If node is a map, keys with nil values will be removed. In case of nested maps, the process is recursive.
(update hmap k f)
(update hmap k f a)
(update hmap k f a b)
(update hmap k f a b c)
(update hmap k f a b c & more)
Just like standard update
but returning a nil value results in the involved key being dissociated.
Just like standard `update` but returning a nil value results in the involved key being dissociated.
(update-in hmap path f & args)
Just like standard update-in
but once again, returning nil results in the involved key being dissociated.
Similarly to dissoc-in
, empty maps are then recursively removed as well.
When an empty path is provided, nothing happens.
Just like standard `update-in` but once again, returning nil results in the involved key being dissociated. Similarly to `dissoc-in`, empty maps are then recursively removed as well. When an empty path is provided, nothing happens.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close