(apply-if pred f & args)
Returns a function that applies f if pred returns true for the specified value.
Usually used in combination with clojure.walk/postwalk
, e.g.
(postwalk (apply-if keyword? str) coll)
Returns a function that applies f if pred returns true for the specified value. Usually used in combination with `clojure.walk/postwalk`, e.g. `(postwalk (apply-if keyword? str) coll)`
(binding-map symbols)
(cljs-env? env)
Take the &env from a macro, and tell whether we are expanding into cljs.
Take the &env from a macro, and tell whether we are expanding into cljs.
(conj-some coll x)
Like conj
but does not add x if x is nil.
Like `conj` but does not add x if x is nil.
(conjt coll x)
Like conj
, keeps the collection type and throws error for seq?
collections,
since it would be very slow (and in the "wrong" order). If coll is nil,
defaults to vector (instead of list as conj does).
Like `conj`, keeps the collection type and throws error for `seq?` collections, since it would be very slow (and in the "wrong" order). If coll is nil, defaults to vector (instead of list as conj does).
(conjt-some coll x)
Like conjt
but does not add x if x is nil.
Like `conjt` but does not add x if x is nil.
(cons-some x coll)
Like cons
but does not add x if x is nil.
Like `cons` but does not add x if x is nil.
(const x coll)
Like cons
but keeps the collection type.
Like `cons` but keeps the collection type.
(const-some x coll)
Like const
but does not add x if x is nil.
Like `const` but does not add x if x is nil.
(dissoc-vals m pred)
Dissoc elements from m for which value matches pred
Dissoc elements from m for which value matches pred
(dprn msg-template & symbols)
Renders the template using the scoped vars, println's the msg and pprint's the arg-map
Renders the template using the scoped vars, println's the msg and pprint's the arg-map
(empty coll)
Like clojure.core/empty with support for map-entry.
Like clojure.core/empty with support for map-entry.
(every-partition? pred n coll)
(every-partition? pred n step coll)
(every-partition? pred n step pad coll)
Is pred true for every partition?
Is pred true for every partition?
(exactly= x y)
Checks that =
is true and that both x and y are of the same type.
Checks that `=` is true and that both x and y are of the same type.
(exceptional f success? get)
Returns a function that applies f and uses the specified get function to retrieve the value if success? returns true for the function application.
Throws an exception if success? returns something falsy.
Returns a function that applies f and uses the specified get function to retrieve the value if success? returns true for the function application. Throws an exception if success? returns something falsy.
(filter-indexes indexes xs)
Selects the items at the indexes.
Example: (select-indexes [0 2] [:a :b :c :d]) ; => [:a :c]
Selects the items at the indexes. Example: (select-indexes [0 2] [:a :b :c :d]) ; => [:a :c]
(filtert pred coll)
Like filter
but keeps the collection type.
Like `filter` but keeps the collection type.
(forv seq-exprs body-expr)
Just like clojure.core/for
, but removes lazyness and returns a vector.
Just like `clojure.core/for`, but removes lazyness and returns a vector.
(guard pred v msg)
(guard pred v msg data-map)
A guard that throws an exception (with msg) if v does not meet pred.
A guard that throws an exception (with msg) if v does not meet pred.
(index-of pred coll)
Returns the index of the first element matching pred in coll
Returns the index of the first element matching pred in coll
(index-of-all pred coll)
Returns the indexes of all elements matching pred in coll
Returns the indexes of all elements matching pred in coll
(into)
(into to)
(into to from)
Like clojure.core/into, but keeps the original order for lists. Does not support transducers.
Like clojure.core/into, but keeps the original order for lists. Does not support transducers.
(mapt f coll)
(mapt f c1 c2)
(mapt f c1 c2 c3)
(mapt f c1 c2 c3 & colls)
Like map
but keeps the collection type. For maps, it assumes that
f returns a pair/map-entry, in order to successfully turn the values
into a map again. When multiple collections are provided, the type of
the first collection determines the return type.
Like `map` but keeps the collection type. For maps, it assumes that f returns a pair/map-entry, in order to successfully turn the values into a map again. When multiple collections are provided, the type of the first collection determines the return type.
(named? x)
Returns true if clojure.core/name
can be called on x.
Returns true if `clojure.core/name` can be called on x.
(partition-indexes indexes xs)
Partitions the seq into the number of specified index partitions. If the index is not specified, it will be put in the last partition.
Example: (partition-indexes [[0 3] [1]] [:a :b :c :d :e]) ;=> [[:a :d] [:b] [:c :e]]
Partitions the seq into the number of specified index partitions. If the index is not specified, it will be put in the last partition. Example: (partition-indexes [[0 3] [1]] [:a :b :c :d :e]) ;=> [[:a :d] [:b] [:c :e]]
(partition-using pred coll)
Collects values to a partition until the pred is true for the partition, and then starts a new partition. If pred never is true, all values ends up in a single partition. Returns a lazy seq of partitions.
When I grow up, I want to return a (stateful) transducer when only pred is provided.
Collects values to a partition until the pred is true for the partition, and then starts a new partition. If pred never is true, all values ends up in a single partition. Returns a lazy seq of partitions. When I grow up, I want to return a (stateful) transducer when only pred is provided.
(qualified-name ident)
Returns a string with the qualified name of the ident
Returns a string with the qualified name of the ident
(qualify-ident nspace nameable)
Qualifies an ident. nspace and nameable must of same
type. The nspace must be a simple-ident?
and nameable
can be either simple-ident?
or qualified-ident?
.
If nameable is already qualified, it will change namespace.
Qualifies an ident. nspace and nameable must of same type. The nspace must be a `simple-ident?` and nameable can be either `simple-ident?` or `qualified-ident?`. If nameable is already qualified, it will change namespace.
(qualify-keys m nspace)
Qualify all the keys in a map
Qualify all the keys in a map
(regex? x)
Test whether x is a regular expression
Test whether x is a regular expression
(remove-indexes indexes xs)
Removes the items at the indexes.
Example: (remove-indexes [0 2] [:a :b :c :d]) ; => [:b :d]
Removes the items at the indexes. Example: (remove-indexes [0 2] [:a :b :c :d]) ; => [:b :d]
(removet pred coll)
Like remove
but keeps the collection type.
Like `remove` but keeps the collection type.
(render-template template args)
Renders the template using args for data. Example:
(render-template "Error: {error-code}" {:error-code 11})
; => "Error: 11"
Renders the template using args for data. Example: `(render-template "Error: {error-code}" {:error-code 11})` ; => "Error: 11"
(seq-> expr & forms)
When expr is a seq (clojure.core/seq
not returns nil), threads it into the
first form (via ->), and when that result is a seq, through the next etc
When expr is a seq (`clojure.core/seq` not returns nil), threads it into the first form (via ->), and when that result is a seq, through the next etc
(seq->> expr & forms)
When expr is a seq (`clojure.core/seq not returns nil), threads it into the first form (via ->>), and when that result is a seq, through the next etc
When expr is a seq (`clojure.core/seq not returns nil), threads it into the first form (via ->>), and when that result is a seq, through the next etc
(seqt coll)
Like seq
but returns the original coll if not empty
Like `seq` but returns the original coll if not empty
(simple-ident ident)
Takes an ident and unqualifies it (removed the namespace). Returns the same
type of ident as was provided. Returns nil if ident
is not an ident.
Takes an ident and unqualifies it (removed the namespace). Returns the same type of ident as was provided. Returns nil if `ident` is not an ident.
(simple-keyword s)
Forces a simple keyword. Useful when forward slashes can
be present in the string s
Forces a simple keyword. Useful when forward slashes can be present in the string `s`
(simple-symbol s)
Forces a simple symbol Useful when forward slashes can
be present in the string s
Forces a simple symbol Useful when forward slashes can be present in the string `s`
(singleton? coll)
Returns true if the coll
has exactly one element, false otherwise.
Returns true if the `coll` has exactly one element, false otherwise.
(some-partition pred n coll)
(some-partition pred n step coll)
(some-partition pred n step pad coll)
some
pred for each partition.
`some` pred for each partition.
(substring s start end)
(template-params template)
Calculate a sequence of params required by the template
Calculate a sequence of params required by the template
(throw-ex msg-template & symbols)
Throw an exception with a msg template and optional vars. The msg template will be rendered using the scoped vars and the template args and vars will be put in the map to ex-info.
Example:
`(let [namn "foohead" age 8] (throw-ex "Hello {namn}" age))
; => {:age 8, :namn "foohead", :msg "Hello foohead"}`
Throw an exception with a msg template and optional vars. The msg template will be rendered using the scoped vars and the template args and vars will be put in the map to ex-info. Example: `(let [namn "foohead" age 8] (throw-ex "Hello {namn}" age)) ; => {:age 8, :namn "foohead", :msg "Hello foohead"}`
(transpose xs)
Transpose a seq of seqs. Returns a vector of vectors.
Transpose a seq of seqs. Returns a vector of vectors.
(unqualify-ident ident)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close