(absorb val form)
Thread val through form if val is not nil.
Thread val through form if val is not nil.
(adjoin left right)
Merge two data structures by combining the contents. For maps, merge recursively by adjoining values with the same key. For collections, combine the right and left using into or conj. If the left value is a set and the right value is a map, the right value is assumed to be an existence map where the value determines whether the key is in the merged set. This makes sets unique from other collections because items can be deleted from them.
Merge two data structures by combining the contents. For maps, merge recursively by adjoining values with the same key. For collections, combine the right and left using into or conj. If the left value is a set and the right value is a map, the right value is assumed to be an existence map where the value determines whether the key is in the merged set. This makes sets unique from other collections because items can be deleted from them.
(all & preds)
Takes a list of predicates and returns a new predicate that returns true if all do.
Takes a list of predicates and returns a new predicate that returns true if all do.
(any & preds)
Takes a list of predicates and returns a new predicate that returns true if any do.
Takes a list of predicates and returns a new predicate that returns true if any do.
(assoc-if map test & kvs)
Create mapping from keys to values in map if test returns true.
Create mapping from keys to values in map if test returns true.
(assoc-in! m [k & ks] v)
Associates a value in a nested associative structure, where ks is a sequence of keys and v is the new value and returns a new nested structure. The associative structure can have transients in it, but if any levels do not exist, non-transient hash-maps will be created.
Associates a value in a nested associative structure, where ks is a sequence of keys and v is the new value and returns a new nested structure. The associative structure can have transients in it, but if any levels do not exist, non-transient hash-maps will be created.
(assoc-or map key val)
(assoc-or map key val & kvs)
Create mapping from each key to val in map only if existing val is nil.
Create mapping from each key to val in map only if existing val is nil.
(comp-partial & fns)
Like comp, except all args but the last are passed to every function with the last arg threaded through these partial functions. So, the rightmost fn is applied to all arguments. Each fn is then applied to the original args with the last arg replaced by the result of the previous fn.
Like comp, except all args but the last are passed to every function with the last arg threaded through these partial functions. So, the rightmost fn is applied to all arguments. Each fn is then applied to the original args with the last arg replaced by the result of the previous fn.
(cond-let test-binding then-form & more)
An implementation of cond-let that is as similar as possible to if-let. Takes multiple test-binding/then-form pairs and evalutes the form if the binding is true. Also supports :else in the place of test-binding and always evaluates the form in that case.
Example: (cond-let [b (bar 1 2 3)] (println :bar b) [f (foo 3 4 5)] (println :foo f) [b (baz 6 7 8)] (println :baz b) :else (println :no-luck))
An implementation of cond-let that is as similar as possible to if-let. Takes multiple test-binding/then-form pairs and evalutes the form if the binding is true. Also supports :else in the place of test-binding and always evaluates the form in that case. Example: (cond-let [b (bar 1 2 3)] (println :bar b) [f (foo 3 4 5)] (println :foo f) [b (baz 6 7 8)] (println :baz b) :else (println :no-luck))
(conj-set coll item)
Conj onto collection ensuring it is a set.
Conj onto collection ensuring it is a set.
(conj-vec coll item)
Conj onto collection ensuring it is a vector.
Conj onto collection ensuring it is a vector.
(construct class & args)
Construct a new instance of class using reflection.
Construct a new instance of class using reflection.
(cross & seqs)
Computes the cartesian-product of the provided seqs. In other words, compute the set of all possible combinations of ways you can choose one item from each seq.
Computes the cartesian-product of the provided seqs. In other words, compute the set of all possible combinations of ways you can choose one item from each seq.
(defm name & fdecl)
(extract pred coll)
Extracts the first item that matches pred from coll, returning a vector of that item followed by coll with the item removed.
Extracts the first item that matches pred from coll, returning a vector of that item followed by coll with the item removed.
(filter-keys pred map)
Returns a map that only contains keys where (pred key) returns true.
Returns a map that only contains keys where (pred key) returns true.
(filter-keys-by-val pred map)
Returns all keys in map for which (pred value) returns true.
Returns all keys in map for which (pred value) returns true.
(filter-vals pred map)
Returns a map that only contains values where (pred value) returns true.
Returns a map that only contains values where (pred value) returns true.
(find-first pred coll)
Returns the first item of coll where (pred item) returns logical true.
Returns the first item of coll where (pred item) returns logical true.
(find-with pred keys vals)
Returns the val corresponding to the first key where (pred key) returns true.
Returns the val corresponding to the first key where (pred key) returns true.
(if-ns ns-reference then-form & [else-form])
Try to load a namespace reference. If successful, evaluate then-form otherwise evaluate else-form.
Try to load a namespace reference. If successful, evaluate then-form otherwise evaluate else-form.
(include? val coll)
Check if val exists in coll.
Check if val exists in coll.
(index-by f coll)
Returns a map from the result of calling f on each item in coll to that item.
Returns a map from the result of calling f on each item in coll to that item.
(into-map & args)
Convert a list of heterogeneous args into a map. Args can be alternating keys and values, maps of keys to values or collections of alternating keys and values.
Convert a list of heterogeneous args into a map. Args can be alternating keys and values, maps of keys to values or collections of alternating keys and values.
(into-vec to-coll from-coll)
Returns a new vector consisting of to-coll with all of the items of from-coll conjoined.
Returns a new vector consisting of to-coll with all of the items of from-coll conjoined.
(invoke-private instance method & params)
Invoke a private or protected Java method. Be very careful when using this! I take no responsibility for the trouble you get yourself into.
Invoke a private or protected Java method. Be very careful when using this! I take no responsibility for the trouble you get yourself into.
(lazy-cross & seqs)
Compute a lazy cartesian-product of the provided seqs. The provided seqs can be lazy or even infinite, and lazy-cross will consume all sequences equally, only consuming more of any sequence when all possible combinations at the current level have been exhausted. This can be thought of intuitively as a breadth-first search of the cartesian product set.
Compute a lazy cartesian-product of the provided seqs. The provided seqs can be lazy or even infinite, and lazy-cross will consume all sequences equally, only consuming more of any sequence when all possible combinations at the current level have been exhausted. This can be thought of intuitively as a breadth-first search of the cartesian product set.
(let-if test bindings & forms)
Choose a set of bindings based on the result of a conditional test.
Example: (let-if (even? a) [b (bar 1 2 3) (baz 1 2 3) c (foo 1) (foo 3)] (println (combine b c)))
Choose a set of bindings based on the result of a conditional test. Example: (let-if (even? a) [b (bar 1 2 3) (baz 1 2 3) c (foo 1) (foo 3)] (println (combine b c)))
(map-reduce map-fn reduce-fn coll)
(map-reduce map-fn reduce-fn reduce-val coll & [map-val])
Perform a map and a reduce over a collection in a single pass. Unlike map, this is not lazy. Returns the equivalent of [(vec (map map-fn coll)) (reduce reduce-fn val coll)].
Perform a map and a reduce over a collection in a single pass. Unlike map, this is not lazy. Returns the equivalent of [(vec (map map-fn coll)) (reduce reduce-fn val coll)].
(map-to f coll)
Returns a map from each item in coll to f applied to that item.
Returns a map from each item in coll to f applied to that item.
(map-vals f m)
Create a new map from m by calling function f on each value to get a new value.
Create a new map from m by calling function f on each value to get a new value.
(map-vals-with-keys f m)
Create a new map from m by calling function f on each key and value to get a new value.
Create a new map from m by calling function f on each key and value to get a new value.
(memoize-deref vars f)
Returns a memoized version a non-referentially transparent function, calling deref on each provided var (or ref or atom) and using that in the cache key to prevent cross-contamination if any of the values change.
Returns a memoized version a non-referentially transparent function, calling deref on each provided var (or ref or atom) and using that in the cache key to prevent cross-contamination if any of the values change.
(on-shutdown f)
Execute the given function on jvm shutdown.
Execute the given function on jvm shutdown.
(or-max & vals)
The maximum value of vals, ignoring nils.
The maximum value of vals, ignoring nils.
(or-min & vals)
The minimium value of vals, ignoring nils.
The minimium value of vals, ignoring nils.
(parse-opts)
(parse-opts args)
(parse-opts default args)
Parse command line args or the provided argument list. Returns a map of keys to vectors of repeated values. Named args begin with --keyname and are mapped to :keyname. Unnamed arguments are mapped to nil or default. Repeated named values can be specified by repeating a key or by using commas in the value. Single and double dashes are both supported though a single dash followed by word characters without internal dashes or an equal sign is assumed to be single character argument flags and are split accordingly.
Example: (parse-opts ["foo" "-vD" "bar" "-no-wrap" "-color=blue,green" "--style=baroque" "-color=red"]) => {:style ["baroque"], :color ["blue" "green" "red"], :no-wrap [""], :D [""], :v [""], nil ["foo" "bar"]}
Parse command line args or the provided argument list. Returns a map of keys to vectors of repeated values. Named args begin with --keyname and are mapped to :keyname. Unnamed arguments are mapped to nil or default. Repeated named values can be specified by repeating a key or by using commas in the value. Single and double dashes are both supported though a single dash followed by word characters without internal dashes or an equal sign is assumed to be single character argument flags and are split accordingly. Example: (parse-opts ["foo" "-vD" "bar" "-no-wrap" "-color=blue,green" "--style=baroque" "-color=red"]) => {:style ["baroque"], :color ["blue" "green" "red"], :no-wrap [""], :D [""], :v [""], nil ["foo" "bar"]}
(pcollect f coll)
(pcollect wrap-fn f coll)
Like pmap but not lazy and more efficient for less computationally intensive functions because there is less coordination overhead. The collection is sliced among the available processors and f is applied to each sub-collection in parallel using map.
Like pmap but not lazy and more efficient for less computationally intensive functions because there is less coordination overhead. The collection is sliced among the available processors and f is applied to each sub-collection in parallel using map.
(pluralize num singular & [plural])
Return a pluralized phrase, appending an s to the singular form if no plural is provided. For example: (plural 5 "month") => "5 months" (plural 1 "month") => "1 month" (plural 1 "radius" "radii") => "1 radius" (plural 9 "radius" "radii") => "9 radii"
Return a pluralized phrase, appending an s to the singular form if no plural is provided. For example: (plural 5 "month") => "5 months" (plural 1 "month") => "1 month" (plural 1 "radius" "radii") => "1 radius" (plural 9 "radius" "radii") => "9 radii"
(position coll)
Returns a map from item to the position of its first occurance in coll.
Returns a map from item to the position of its first occurance in coll.
(queue)
(queue seq)
Create an empty persistent queue or a persistent queue from a sequence.
Create an empty persistent queue or a persistent queue from a sequence.
(remove-keys pred map)
Returns a map that only contains keys where (pred key) returns false.
Returns a map that only contains keys where (pred key) returns false.
(remove-keys-by-val pred map)
Returns all keys of map for which (pred value) returns false.
Returns all keys of map for which (pred value) returns false.
(remove-vals pred map)
Returns a map that only contains values where (pred value) returns false.
Returns a map that only contains values where (pred value) returns false.
(rescue form error-form)
Evaluate form, returning error-form on any Exception.
Evaluate form, returning error-form on any Exception.
(separate pred coll)
Split coll into two sequences, one that matches pred and one that doesn't. Unlike the version in clojure.contrib.seq-utils, pred is only called once per item.
Split coll into two sequences, one that matches pred and one that doesn't. Unlike the version in clojure.contrib.seq-utils, pred is only called once per item.
(slice n coll)
Divide coll into n approximately equal slices.
Divide coll into n approximately equal slices.
(split-vec v & ns)
Split the given vector at the provided offsets using subvec. Supports negative offsets.
Split the given vector at the provided offsets using subvec. Supports negative offsets.
(syntax-quote form)
Syntax quote the given form, wrapping all seqs and symbols in quote.
Syntax quote the given form, wrapping all seqs and symbols in quote.
(tap f obj)
Call f on obj, presumably with side effects, then return obj. Useful for debugging when you want to print an object inline. e.g. (tap println foo)
Call f on obj, presumably with side effects, then return obj. Useful for debugging when you want to print an object inline. e.g. (tap println foo)
(thrush & args)
Takes the first argument and applies the remaining arguments to it as functions from left to right. This tiny implementation was written by Chris Houser. http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux
Takes the first argument and applies the remaining arguments to it as functions from left to right. This tiny implementation was written by Chris Houser. http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux
(trap signal f)
Register signal handling function.
Register signal handling function.
(update map key f & args)
Update value in map where f is a function that takes the old value and the supplied args and returns the new value. For efficiency, Do not change map if the old value is the same as the new value. If key is sequential, update all keys in the sequence with the same function.
Update value in map where f is a function that takes the old value and the supplied args and returns the new value. For efficiency, Do not change map if the old value is the same as the new value. If key is sequential, update all keys in the sequence with the same function.
(update-in! m [k & ks] f & args)
'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. The associative structure can have transients in it, but if any levels do not exist, non-transient hash-maps will be created.
'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. The associative structure can have transients in it, but if any levels do not exist, non-transient hash-maps will be created.
(verify test exception)
Raise exception unless test returns true.
Raise exception unless test returns true.
(while-let bindings & body)
Repeatedly executes body, which presumably has side-effects, while let binding is not false.
Repeatedly executes body, which presumably has side-effects, while let binding is not false.
(wrap-bindings vars f)
Wrap f in a new fuction that re-establishes the current binding for the given vars.
Wrap f in a new fuction that re-establishes the current binding for the given vars.
(zip & colls)
Returns a lazy sequence of vectors of corresponding items from each collection. If one collection is longer than the others, the missing items will be filled in with nils.
Returns a lazy sequence of vectors of corresponding items from each collection. If one collection is longer than the others, the missing items will be filled in with nils.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close