A small collection of useful, mostly pure functions that might not look out of place in the clojure.core namespace.
A small collection of useful, mostly pure functions that might not look out of place in the clojure.core namespace.
(abs x)
Returns the absolute value of a number.
Returns the absolute value of a number.
(assoc-some m k v)
(assoc-some m k v & kvs)
Associates a key with a value in a map, if and only if the value is not nil.
Associates a key with a value in a map, if and only if the value is not nil.
(boolean? x)
Returns true if x is a boolean.
Returns true if x is a boolean.
(deref-reset! atom newval)
Sets the value of the atom without regard for the current value, then returns
the original value of the atom. See also: deref-swap!
.
Sets the value of the atom without regard for the current value, then returns the original value of the atom. See also: [[deref-swap!]].
(deref-swap! atom f & args)
(deref-swap! atom f)
(deref-swap! atom f & args)
Atomically swaps the value of the atom to be (apply f x args)
, where x is
the current value of the atom, then returns the original value of the atom.
This function therefore acts like an atomic deref
then swap!
.
Atomically swaps the value of the atom to be `(apply f x args)`, where x is the current value of the atom, then returns the original value of the atom. This function therefore acts like an atomic `deref` then `swap!`.
(dissoc-in m ks)
Dissociate a value in a nested assocative structure, identified by a sequence of keys. Any collections left empty by the operation will be dissociated from their containing structures.
Dissociate a value in a nested assocative structure, identified by a sequence of keys. Any collections left empty by the operation will be dissociated from their containing structures.
(distinct-by f coll)
Returns a lazy sequence of the elements of coll, removing any elements that return duplicate values when passed to a function f.
Returns a lazy sequence of the elements of coll, removing any elements that return duplicate values when passed to a function f.
(drop-upto pred coll)
Returns a lazy sequence of the items in coll starting after the first item
for which (pred item)
returns true.
Returns a lazy sequence of the items in coll starting *after* the first item for which `(pred item)` returns true.
(ex-cause ex)
Returns the cause attached to the given ExceptionInfo/Throwable object. For
all other types returns nil. Same as cljs.core/ex-clause
except it works for
Clojure as well as ClojureScript.
Returns the cause attached to the given ExceptionInfo/Throwable object. For all other types returns nil. Same as `cljs.core/ex-clause` except it works for Clojure as well as ClojureScript.
(ex-message ex)
Returns the message attached to the given Error/Throwable object. For all
other types returns nil. Same as cljs.core/ex-message
except it works for
Clojure as well as ClojureScript.
Returns the message attached to the given Error/Throwable object. For all other types returns nil. Same as `cljs.core/ex-message` except it works for Clojure as well as ClojureScript.
(filter-keys pred coll)
Returns a new associative collection of the items in coll for which
(pred (key item))
returns true.
Returns a new associative collection of the items in coll for which `(pred (key item))` returns true.
(filter-kv pred coll)
Returns a new associative collection of the items in coll for which
(pred (key item) (val item))
returns true.
Returns a new associative collection of the items in coll for which `(pred (key item) (val item))` returns true.
(filter-vals pred coll)
Returns a new associative collection of the items in coll for which
(pred (val item))
returns true.
Returns a new associative collection of the items in coll for which `(pred (val item))` returns true.
(find-first pred coll)
Finds the first item in a collection that matches a predicate.
Finds the first item in a collection that matches a predicate.
(greatest & xs)
(greatest)
(greatest a)
(greatest a b)
(greatest a b & more)
Find the greatest argument (as defined by the compare function) in O(n) time.
Find the greatest argument (as defined by the compare function) in O(n) time.
(in? item coll)
Determines whether item is included in the seqable collection.
Determines whether item is included in the seqable collection.
(indexed coll)
Returns an ordered, lazy sequence of vectors [index item]
, where item is a
value in coll, and index its position starting from zero.
Returns an ordered, lazy sequence of vectors `[index item]`, where item is a value in coll, and index its position starting from zero.
(indexed-map coll & {:keys [index-key] :or {index-key :id}})
Turns a list of maps into a map, indexed by index-key.
Turns a list of maps into a map, indexed by index-key.
(interleave-all & colls)
(interleave-all)
(interleave-all c1)
(interleave-all c1 c2)
(interleave-all c1 c2 & colls)
Returns a lazy seq of the first item in each coll, then the second, etc.
Unlike clojure.core/interleave
, the returned seq contains all items in the
supplied collections, even if the collections are different sizes.
Returns a lazy seq of the first item in each coll, then the second, etc. Unlike `clojure.core/interleave`, the returned seq contains all items in the supplied collections, even if the collections are different sizes.
(least & xs)
(least)
(least a)
(least a b)
(least a b & more)
Return the least argument (as defined by the compare function) in O(n) time.
Return the least argument (as defined by the compare function) in O(n) time.
(map-entry k v)
Create a map entry for a key and value pair.
Create a map entry for a key and value pair.
(map-keys f coll)
Maps a function over the keys of an associative collection.
Maps a function over the keys of an associative collection.
(map-kv f coll)
Maps a function over the key/value pairs of an associate collection. Expects a function that takes two arguments, the key and value, and returns the new key and value as a collection of two elements.
Maps a function over the key/value pairs of an associate collection. Expects a function that takes two arguments, the key and value, and returns the new key and value as a collection of two elements.
(map-vals f coll)
Maps a function over the values of an associative collection.
Maps a function over the values of an associative collection.
(mapply f & args)
(mapply f m)
(mapply f a & args)
Applies a function f to the argument list formed by concatenating everything but the last element of args with the last element of args. This is useful for applying a function that accepts keyword arguments to a map.
Applies a function f to the argument list formed by concatenating everything but the last element of args with the last element of args. This is useful for applying a function that accepts keyword arguments to a map.
(queue)
(queue coll)
Creates an empty persistent queue, or one populated with a collection.
Creates an empty persistent queue, or one populated with a collection.
(queue? x)
Returns true if x implements clojure.lang.PersistentQueue.
Returns true if x implements clojure.lang.PersistentQueue.
(random-uuid)
Generates a new random UUID. Same as cljs.core/random-uuid
except it works
for Clojure as well as ClojureScript.
Generates a new random UUID. Same as `cljs.core/random-uuid` except it works for Clojure as well as ClojureScript.
(remove-keys pred coll)
Returns a new associative collection of the items in coll for which
(pred (key item))
returns false.
Returns a new associative collection of the items in coll for which `(pred (key item))` returns false.
(remove-kv pred coll)
Returns a new associative collection of the items in coll for which
(pred (key item) (val item))
returns false.
Returns a new associative collection of the items in coll for which `(pred (key item) (val item))` returns false.
(remove-vals pred coll)
Returns a new associative collection of the items in coll for which
(pred (val item))
returns false.
Returns a new associative collection of the items in coll for which `(pred (val item))` returns false.
(take-upto pred coll)
Returns a lazy sequence of successive items from coll up to and including
the first item for which (pred item)
returns true.
Returns a lazy sequence of successive items from coll up to and including the first item for which `(pred item)` returns true.
(uuid s)
Returns a UUID generated from the supplied string. Same as cljs.core/uuid
in ClojureScript, while in Clojure it returns a java.util.UUID
object.
Returns a UUID generated from the supplied string. Same as `cljs.core/uuid` in ClojureScript, while in Clojure it returns a `java.util.UUID` object.
(uuid? x)
Returns true if the value is a UUID.
Returns true if the value is a UUID.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close