Coll-first wrappers for clojure.core sequence functions.
Every public var is a pure rename of the clojure.core fn of the same name: same behavior, with the primary collection moved to argument 1 (any further collections stay after the function, in core's order).
Recommended usage is an alias:
(ns my.app
(:require [consistent-lib.core :as c]))
(-> [1 2 3 4]
(c/map inc)
(c/filter even?))
Avoid (:require [consistent-lib.core :refer :all]): almost every name here
shadows a clojure.core fn (map, filter, reduce, take, ...), so a blanket
refer replaces every clojure.core var of the same name, the compiler warns
about each replaced var, and unqualified calls to those names in that
namespace then use the coll-first order. If you :refer specific names,
exclude them from clojure.core too, e.g. (:refer-clojure :exclude [map]).
Coll-first wrappers for clojure.core sequence functions.
Every public var is a pure rename of the clojure.core fn of the same name:
same behavior, with the primary collection moved to argument 1 (any
further collections stay after the function, in core's order).
Recommended usage is an alias:
(ns my.app
(:require [consistent-lib.core :as c]))
(-> [1 2 3 4]
(c/map inc)
(c/filter even?))
Avoid `(:require [consistent-lib.core :refer :all])`: almost every name here
shadows a clojure.core fn (map, filter, reduce, take, ...), so a blanket
refer replaces every clojure.core var of the same name, the compiler warns
about each replaced var, and unqualified calls to those names in that
namespace then use the coll-first order. If you `:refer` specific names,
exclude them from clojure.core too, e.g. `(:refer-clojure :exclude [map])`.(drop n)(drop coll n)consistent-lib: coll-first wrapper for clojure.core/drop — same behavior, collection first (see :arglists above).
Returns a lazy sequence of all but the first n items in coll. Returns a stateful transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/drop — same behavior, collection first (see :arglists above). Returns a lazy sequence of all but the first n items in coll. Returns a stateful transducer when no collection is provided.
(drop-last coll)(drop-last coll n)consistent-lib: coll-first wrapper for clojure.core/drop-last — same behavior, collection first (see :arglists above).
Return a lazy sequence of all but the last n (default 1) items in coll
consistent-lib: coll-first wrapper for clojure.core/drop-last — same behavior, collection first (see :arglists above). Return a lazy sequence of all but the last n (default 1) items in coll
(drop-while pred)(drop-while coll pred)consistent-lib: coll-first wrapper for clojure.core/drop-while — same behavior, collection first (see :arglists above).
Returns a lazy sequence of the items in coll starting from the first item for which (pred item) returns logical false. Returns a stateful transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/drop-while — same behavior, collection first (see :arglists above). Returns a lazy sequence of the items in coll starting from the first item for which (pred item) returns logical false. Returns a stateful transducer when no collection is provided.
(eduction coll & xforms)consistent-lib: coll-first wrapper for clojure.core/eduction — same behavior, collection first (see :arglists above).
Returns a reducible/iterable application of the transducers to the items in coll. Transducers are applied in order as if combined with comp. Note that these applications will be performed every time reduce/iterator is called.
consistent-lib: coll-first wrapper for clojure.core/eduction — same behavior, collection first (see :arglists above). Returns a reducible/iterable application of the transducers to the items in coll. Transducers are applied in order as if combined with comp. Note that these applications will be performed every time reduce/iterator is called.
(every? coll pred)consistent-lib: coll-first wrapper for clojure.core/every? — same behavior, collection first (see :arglists above).
Returns true if (pred x) is logical true for every x in coll, else false.
consistent-lib: coll-first wrapper for clojure.core/every? — same behavior, collection first (see :arglists above). Returns true if (pred x) is logical true for every x in coll, else false.
(filter pred)(filter coll pred)consistent-lib: coll-first wrapper for clojure.core/filter — same behavior, collection first (see :arglists above).
Returns a lazy sequence of the items in coll for which (pred item) returns logical true. pred must be free of side-effects. Returns a transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/filter — same behavior, collection first (see :arglists above). Returns a lazy sequence of the items in coll for which (pred item) returns logical true. pred must be free of side-effects. Returns a transducer when no collection is provided.
(filterv coll pred)consistent-lib: coll-first wrapper for clojure.core/filterv — same behavior, collection first (see :arglists above).
Returns a vector of the items in coll for which (pred item) returns logical true. pred must be free of side-effects.
consistent-lib: coll-first wrapper for clojure.core/filterv — same behavior, collection first (see :arglists above). Returns a vector of the items in coll for which (pred item) returns logical true. pred must be free of side-effects.
(group-by coll f)consistent-lib: coll-first wrapper for clojure.core/group-by — same behavior, collection first (see :arglists above).
Returns a map of the elements of coll keyed by the result of f on each element. The value at each key will be a vector of the corresponding elements, in the order they appeared in coll.
consistent-lib: coll-first wrapper for clojure.core/group-by — same behavior, collection first (see :arglists above). Returns a map of the elements of coll keyed by the result of f on each element. The value at each key will be a vector of the corresponding elements, in the order they appeared in coll.
(interpose separator)(interpose coll separator)consistent-lib: coll-first wrapper for clojure.core/interpose — same behavior, collection first (see :arglists above).
Returns a lazy seq of the elements of coll separated by sep. Returns a stateful transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/interpose — same behavior, collection first (see :arglists above). Returns a lazy seq of the elements of coll separated by sep. Returns a stateful transducer when no collection is provided.
(keep f)(keep coll f)consistent-lib: coll-first wrapper for clojure.core/keep — same behavior, collection first (see :arglists above).
Returns a lazy sequence of the non-nil results of (f item). Note, this means false return values will be included. f must be free of side-effects. Returns a transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/keep — same behavior, collection first (see :arglists above). Returns a lazy sequence of the non-nil results of (f item). Note, this means false return values will be included. f must be free of side-effects. Returns a transducer when no collection is provided.
(keep-indexed f)(keep-indexed coll f)consistent-lib: coll-first wrapper for clojure.core/keep-indexed — same behavior, collection first (see :arglists above).
Returns a lazy sequence of the non-nil results of (f index item). Note, this means false return values will be included. f must be free of side-effects. Returns a stateful transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/keep-indexed — same behavior, collection first (see :arglists above). Returns a lazy sequence of the non-nil results of (f index item). Note, this means false return values will be included. f must be free of side-effects. Returns a stateful transducer when no collection is provided.
(map f)(map coll f)(map coll f c2)(map coll f c2 c3)(map coll f c2 c3 & colls)consistent-lib: coll-first wrapper for clojure.core/map — same behavior, collection first (see :arglists above).
Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments. Returns a transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/map — same behavior, collection first (see :arglists above). Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments. Returns a transducer when no collection is provided.
(map-indexed f)(map-indexed coll f)consistent-lib: coll-first wrapper for clojure.core/map-indexed — same behavior, collection first (see :arglists above).
Returns a lazy sequence consisting of the result of applying f to 0 and the first item of coll, followed by applying f to 1 and the second item in coll, etc, until coll is exhausted. Thus function f should accept 2 arguments, index and item. Returns a stateful transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/map-indexed — same behavior, collection first (see :arglists above). Returns a lazy sequence consisting of the result of applying f to 0 and the first item of coll, followed by applying f to 1 and the second item in coll, etc, until coll is exhausted. Thus function f should accept 2 arguments, index and item. Returns a stateful transducer when no collection is provided.
(mapcat f)(mapcat coll f & colls)consistent-lib: coll-first wrapper for clojure.core/mapcat — same behavior, collection first (see :arglists above).
Returns the result of applying concat to the result of applying map to f and colls. Thus function f should return a collection. Returns a transducer when no collections are provided
consistent-lib: coll-first wrapper for clojure.core/mapcat — same behavior, collection first (see :arglists above). Returns the result of applying concat to the result of applying map to f and colls. Thus function f should return a collection. Returns a transducer when no collections are provided
(mapv coll f)(mapv coll f c2)(mapv coll f c2 c3)(mapv coll f c2 c3 & colls)consistent-lib: coll-first wrapper for clojure.core/mapv — same behavior, collection first (see :arglists above).
Returns a vector consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments.
consistent-lib: coll-first wrapper for clojure.core/mapv — same behavior, collection first (see :arglists above). Returns a vector consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments.
(not-any? coll pred)consistent-lib: coll-first wrapper for clojure.core/not-any? — same behavior, collection first (see :arglists above).
Returns false if (pred x) is logical true for any x in coll, else true.
consistent-lib: coll-first wrapper for clojure.core/not-any? — same behavior, collection first (see :arglists above). Returns false if (pred x) is logical true for any x in coll, else true.
(not-every? coll pred)consistent-lib: coll-first wrapper for clojure.core/not-every? — same behavior, collection first (see :arglists above).
Returns false if (pred x) is logical true for every x in coll, else true.
consistent-lib: coll-first wrapper for clojure.core/not-every? — same behavior, collection first (see :arglists above). Returns false if (pred x) is logical true for every x in coll, else true.
(partition coll n)(partition coll n step)(partition coll n step pad)consistent-lib: coll-first wrapper for clojure.core/partition — same behavior, collection first (see :arglists above).
Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items.
consistent-lib: coll-first wrapper for clojure.core/partition — same behavior, collection first (see :arglists above). Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items.
(partition-all n)(partition-all coll n)(partition-all coll n step)consistent-lib: coll-first wrapper for clojure.core/partition-all — same behavior, collection first (see :arglists above).
Returns a lazy sequence of lists like partition, but may include partitions with fewer than n items at the end. Returns a stateful transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/partition-all — same behavior, collection first (see :arglists above). Returns a lazy sequence of lists like partition, but may include partitions with fewer than n items at the end. Returns a stateful transducer when no collection is provided.
(partition-by f)(partition-by coll f)consistent-lib: coll-first wrapper for clojure.core/partition-by — same behavior, collection first (see :arglists above).
Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of partitions. Returns a stateful transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/partition-by — same behavior, collection first (see :arglists above). Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of partitions. Returns a stateful transducer when no collection is provided.
(reduce coll f)(reduce coll f init)consistent-lib: coll-first wrapper for clojure.core/reduce — same behavior, collection first (see :arglists above).
f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val is supplied, returns the result of applying f to val and the first item in coll, then applying f to that result and the 2nd item, etc. If coll contains no items, returns val and f is not called.
consistent-lib: coll-first wrapper for clojure.core/reduce — same behavior, collection first (see :arglists above). f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val is supplied, returns the result of applying f to val and the first item in coll, then applying f to that result and the 2nd item, etc. If coll contains no items, returns val and f is not called.
(reduce-kv coll f init)consistent-lib: coll-first wrapper for clojure.core/reduce-kv — same behavior, collection first (see :arglists above).
Reduces an associative collection. f should be a function of 3 arguments. Returns the result of applying f to init, the first key and the first value in coll, then applying f to that result and the 2nd key and value, etc. If coll contains no entries, returns init and f is not called. Note that reduce-kv is supported on vectors, where the keys will be the ordinals.
consistent-lib: coll-first wrapper for clojure.core/reduce-kv — same behavior, collection first (see :arglists above). Reduces an associative collection. f should be a function of 3 arguments. Returns the result of applying f to init, the first key and the first value in coll, then applying f to that result and the 2nd key and value, etc. If coll contains no entries, returns init and f is not called. Note that reduce-kv is supported on vectors, where the keys will be the ordinals.
(reductions coll f)(reductions coll f init)consistent-lib: coll-first wrapper for clojure.core/reductions — same behavior, collection first (see :arglists above).
Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init.
consistent-lib: coll-first wrapper for clojure.core/reductions — same behavior, collection first (see :arglists above). Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init.
(remove pred)(remove coll pred)consistent-lib: coll-first wrapper for clojure.core/remove — same behavior, collection first (see :arglists above).
Returns a lazy sequence of the items in coll for which (pred item) returns logical false. pred must be free of side-effects. Returns a transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/remove — same behavior, collection first (see :arglists above). Returns a lazy sequence of the items in coll for which (pred item) returns logical false. pred must be free of side-effects. Returns a transducer when no collection is provided.
(replace smap)(replace coll smap)consistent-lib: coll-first wrapper for clojure.core/replace — same behavior, collection first (see :arglists above).
Given a map of replacement pairs and a vector/collection, returns a vector/seq with any elements = a key in smap replaced with the corresponding val in smap. Returns a transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/replace — same behavior, collection first (see :arglists above). Given a map of replacement pairs and a vector/collection, returns a vector/seq with any elements = a key in smap replaced with the corresponding val in smap. Returns a transducer when no collection is provided.
(run! coll proc)consistent-lib: coll-first wrapper for clojure.core/run! — same behavior, collection first (see :arglists above).
Runs the supplied procedure (via reduce), for purposes of side effects, on successive items in the collection. Returns nil
consistent-lib: coll-first wrapper for clojure.core/run! — same behavior, collection first (see :arglists above). Runs the supplied procedure (via reduce), for purposes of side effects, on successive items in the collection. Returns nil
(sequence coll)(sequence coll xform)(sequence coll xform & colls)consistent-lib: coll-first wrapper for clojure.core/sequence — same behavior, collection first (see :arglists above).
Coerces coll to a (possibly empty) sequence, if it is not already one. Will not force a lazy seq. (sequence nil) yields (), When a transducer is supplied, returns a lazy sequence of applications of the transform to the items in coll(s), i.e. to the set of first items of each coll, followed by the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. The transform should accept number-of-colls arguments
consistent-lib: coll-first wrapper for clojure.core/sequence — same behavior, collection first (see :arglists above). Coerces coll to a (possibly empty) sequence, if it is not already one. Will not force a lazy seq. (sequence nil) yields (), When a transducer is supplied, returns a lazy sequence of applications of the transform to the items in coll(s), i.e. to the set of first items of each coll, followed by the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. The transform should accept number-of-colls arguments
(some coll pred)consistent-lib: coll-first wrapper for clojure.core/some — same behavior, collection first (see :arglists above).
Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)
consistent-lib: coll-first wrapper for clojure.core/some — same behavior, collection first (see :arglists above).
Returns the first logical true value of (pred x) for any x in coll,
else nil. One common idiom is to use a set as pred, for example
this will return :fred if :fred is in the sequence, otherwise nil:
(some #{:fred} coll)(sort coll)(sort coll comp)consistent-lib: coll-first wrapper for clojure.core/sort — same behavior, collection first (see :arglists above).
Returns a sorted sequence of the items in coll. If no comparator is supplied, uses compare. comparator must implement java.util.Comparator. Guaranteed to be stable: equal elements will not be reordered. If coll is a Java array, it will be modified. To avoid this, sort a copy of the array.
consistent-lib: coll-first wrapper for clojure.core/sort — same behavior, collection first (see :arglists above). Returns a sorted sequence of the items in coll. If no comparator is supplied, uses compare. comparator must implement java.util.Comparator. Guaranteed to be stable: equal elements will not be reordered. If coll is a Java array, it will be modified. To avoid this, sort a copy of the array.
(sort-by coll keyfn)(sort-by coll keyfn comp)consistent-lib: coll-first wrapper for clojure.core/sort-by — same behavior, collection first (see :arglists above).
Returns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). If no comparator is supplied, uses compare. comparator must implement java.util.Comparator. Guaranteed to be stable: equal elements will not be reordered. If coll is a Java array, it will be modified. To avoid this, sort a copy of the array.
consistent-lib: coll-first wrapper for clojure.core/sort-by — same behavior, collection first (see :arglists above). Returns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). If no comparator is supplied, uses compare. comparator must implement java.util.Comparator. Guaranteed to be stable: equal elements will not be reordered. If coll is a Java array, it will be modified. To avoid this, sort a copy of the array.
(split-at coll idx)consistent-lib: coll-first wrapper for clojure.core/split-at — same behavior, collection first (see :arglists above).
Returns a vector of [(take n coll) (drop n coll)]
consistent-lib: coll-first wrapper for clojure.core/split-at — same behavior, collection first (see :arglists above). Returns a vector of [(take n coll) (drop n coll)]
(split-with coll pred)consistent-lib: coll-first wrapper for clojure.core/split-with — same behavior, collection first (see :arglists above).
Returns a vector of [(take-while pred coll) (drop-while pred coll)]
consistent-lib: coll-first wrapper for clojure.core/split-with — same behavior, collection first (see :arglists above). Returns a vector of [(take-while pred coll) (drop-while pred coll)]
(take n)(take coll n)consistent-lib: coll-first wrapper for clojure.core/take — same behavior, collection first (see :arglists above).
Returns a lazy sequence of the first n items in coll, or all items if there are fewer than n. Returns a stateful transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/take — same behavior, collection first (see :arglists above). Returns a lazy sequence of the first n items in coll, or all items if there are fewer than n. Returns a stateful transducer when no collection is provided.
(take-last coll n)consistent-lib: coll-first wrapper for clojure.core/take-last — same behavior, collection first (see :arglists above).
Returns a seq of the last n items in coll. Depending on the type of coll may be no better than linear time. For vectors, see also subvec.
consistent-lib: coll-first wrapper for clojure.core/take-last — same behavior, collection first (see :arglists above). Returns a seq of the last n items in coll. Depending on the type of coll may be no better than linear time. For vectors, see also subvec.
(take-nth n)(take-nth coll n)consistent-lib: coll-first wrapper for clojure.core/take-nth — same behavior, collection first (see :arglists above).
Returns a lazy seq of every nth item in coll. Returns a stateful transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/take-nth — same behavior, collection first (see :arglists above). Returns a lazy seq of every nth item in coll. Returns a stateful transducer when no collection is provided.
(take-while pred)(take-while coll pred)consistent-lib: coll-first wrapper for clojure.core/take-while — same behavior, collection first (see :arglists above).
Returns a lazy sequence of successive items from coll while (pred item) returns logical true. pred must be free of side-effects. Returns a transducer when no collection is provided.
consistent-lib: coll-first wrapper for clojure.core/take-while — same behavior, collection first (see :arglists above). Returns a lazy sequence of successive items from coll while (pred item) returns logical true. pred must be free of side-effects. Returns a transducer when no collection is provided.
(transduce coll xform f)(transduce coll xform f init)consistent-lib: coll-first wrapper for clojure.core/transduce — same behavior, collection first (see :arglists above).
reduce with a transformation of f (xf). If init is not supplied, (f) will be called to produce it. f should be a reducing step function that accepts both 1 and 2 arguments, if it accepts only 2 you can add the arity-1 with 'completing'. Returns the result of applying (the transformed) xf to init and the first item in coll, then applying xf to that result and the 2nd item, etc. If coll contains no items, returns init and f is not called. Note that certain transforms may inject or skip items.
consistent-lib: coll-first wrapper for clojure.core/transduce — same behavior, collection first (see :arglists above). reduce with a transformation of f (xf). If init is not supplied, (f) will be called to produce it. f should be a reducing step function that accepts both 1 and 2 arguments, if it accepts only 2 you can add the arity-1 with 'completing'. Returns the result of applying (the transformed) xf to init and the first item in coll, then applying xf to that result and the 2nd item, etc. If coll contains no items, returns init and f is not called. Note that certain transforms may inject or skip items.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |