Immutable, mutable and persistent collections. Reducers and transducers .

In Dunaj, a collection in a broadest sense is defined as an object that implements IRed. There are no other requirements for such object. In Dunaj, any object is considered a collection as long as it is reducible by implementing IRed protocol. Predicate for such collection is called red?. Other names for a collection that at least implements IRed include ‘reducible’, ‘reducible collection’ or just ‘a collection’ (last one is the most used in Dunaj docs).

Major groups of collections

In addition to reducible collections, dunaj defines 5 mutually exclusive groups of collections:

Immutable collections

  • implement IRed

  • do not implement IPersistentCollection nor ISeq

  • are not persistent

  • can be IEditable - return mutable collection, preferably transient

  • have items stored in memory or lazily evaluated with caching

  • examples: String, ArrayColl or ImmutableBuffer

Persistent collections

  • implement IRed and IPersistentCollection

  • do not implement ISeq

  • can be IEditable - return mutable collection, preferably transient

  • have items stored in memory or lazily evaluated with caching

    • in later case, time guarantees may not be met on a first call, when lazy parts of the collection are realized.

  • examples: ArrayMap, BvtVector

Seqs

  • implement IRed, IPersistentCollection and ISeq

  • are usually wrappers on top of other collections

  • have items stored in memory or lazily evaluated with caching

  • examples: LinkedList, Lazy, Cons

Mutable collections

  • do not necessarily implement IRed

  • if implement IRed, must also be IThreadLocal or ISnapshotable

  • implement some mutable protocols, usually IMutableCollection

  • can be ISettleable or ISnapshotable

  • transient collections are mutable collections that implement at least IRed, IThreadLocal and ISettleable

  • examples: collections created with edit!, concurrent hash-trie, Buffer

Collection recipes

  • implement IRed

  • do not implement IPersistentCollecion or IMutableCollection

  • no items stored in memory, recompute for each reduce

  • may give different results for same reduce calls, when e.g. connected to a resource, represent a random number generator or when the computation they perform takes values from some reference or mutable collection.

  • can represent input from a resource, performing I/O operations when reduced. Such collections must be reduced within dunaj.state/io! block.

  • examples:

Host or third party collections can be easily integrated with Dunaj collections by extending IRed (and optionally other Dunaj collection protocols). Standard host collections are already supported, and extensions are available for host interfaces too (e.g. j.u.List, j.u.Collection on JVM)

A host array is not considered a collection. Use dunaj.host.array/adapt function to transform array into a Dunaj collection variant.

Every collection which implements IRed is seqable (transformable to ISeq) in O(1).

Docstrings mention what kind of collection they expect or provide:

  • e.g. if docstring states that a function accepts a collection, user can pass any object implementing IRed

  • pay attention to what kind of collection a function produces (e.g. map, take or filter all return collection recipes!)

Primary

Postponed

Available since version 1.0 (view source)

TYPE

Extends: IReference

A type for postponed reduction. A continuation for reductions. Holds an intermediate result, accessible by dereferencing the postponed object. Reduction can be continued by calling advance or unsafe-advance! functions.

Reduced

Available since version 1.0 (view source)

TYPE

Extends: IReference

A reduced reference type. Signals that reduction should finish early.

See also: reduced?, reduced

Transducer

Available since version 1.0 (view source)

VAR of type Signature

A type signature for transducers.

advance

Available since version 1.0 (view source)

Usage:
  • (advance postponed)

Type signature:
  • (Postponed) → Any

Continues with the reduction of a postponed result and returns the reduced result, applying same rules as in the reduce function. May again return another postponed object. Usually much slower than unsafe-advance!, but can be called multiple times for same postponed object. May not always be supported.

ensure-batchable

Available since version 1.0 (view source)

Usage:
  • (ensure-batchable coll)

Type signature:
  • (Any) → IBatchedRed

Returns coll, throwing if it is not batchable.

See also: ensure-unpackable

ensure-unpackable

Available since version 1.0 (view source)

Usage:
  • (ensure-unpackable coll)

Type signature:
  • (Any) → IUnpackedRed

Returns coll, throwing if it is not unpackable.

See also: ensure-batchable

ffirst

Available since version 1.0 (view source)

Usage:
  • (ffirst coll)

  • (ffirst coll not-found)

Type signatures:
  • ([]) → Any

  • ([] ⨯ Any) → Any

Returns the first item of the first item in the collection coll, or not-found (defaults to nil) if coll is nil or empty.

See also: first, second, seq, rest

first

Available since version 1.0 (view source)

Usage:
  • (first coll)

  • (first coll not-found)

Type signatures:
  • ([]) → Any

  • ([] ⨯ Any) → Any

Returns the first item in the collection coll, or not-found (defaults to nil) if coll is nil or empty.

See also: second, ffirst, rest, next

postponed

Available since version 1.0 (view source)

Usage:
  • (postponed ret)

  • (postponed ret advancef uadvancef)

Type signatures:
  • (Any) → Postponed

  • (Any ⨯ AnyFn ⨯ AnyFn) → Postponed

Returns a postponed reference to the intermediate result ret, with advancef as a function that continues the reduction in a safe way (can call advance on same object multiple times), with uadvancef as a function that continues the reduction in an unsafe way (one call to unsafe-advance! per object only), and which defaults to (constantly ret). The caller can get the intermediate result by dereferencing the returned object. The reduction can be continued by calling advance or unsafe-advance! function.

postponed?

Available since version 1.0 (view source)

Usage:
  • (postponed? x)

Type signature: Predicate

Returns true if object x is an instance of Postponed type, false otherwise.

provide-collection

Available since version 1.0 (view source)

Usage:
  • (provide-collection x)

Type signature:
  • (Any) → IRed

Returns x if it is a collection, otherwise returns a list containing x.

provide-sequential

Available since version 1.0 (view source)

Usage:
  • (provide-sequential x)

Type signature:
  • (Any) → IRed

Returns x if it is a sequential collection, otherwise returns list containing x.

red?

Available since version 1.0 (view source)

Usage:
  • (red? x)

Type signature: Predicate

Returns true if object x satisfies IRed protocol, false otherwise.

reduce

Available since version 1.0 (view source)

Usage:
  • (reduce reducef coll)

  • (reduce reducef init coll)

Type signatures:
  • (AnyFn ⨯ []) → Any

  • (AnyFn ⨯ Any ⨯ []) → Any

Returns the reduction of coll with a reducing function reducef and with a starting value init, or returns an Postponed reference holding the intermediate result, if the reduction was postponed either from the reducef or by the collection itself. The reduction can then be continued by calling advance function on the postponed reference.

Reduction process may be controlled in reducef by returning reduced or postponed references. If init is not supplied, (reducef) is used instead. In either case, the initial value may not be a postponed or reduced object.

Reducing function reducef should behave differently based on number of arguments:

  • (reducef) - returns identity value. Used only if initial value init is not provided by the caller.

  • (reducef ret val) - applies val on the ret result of a previous reduction step.

  • (reducef ret val & more) - used in multireducibles, applies val and all other arguments into ret. Number of required arguments is specified by the multireducible collection coll.

reduce-augmented

Available since version 1.0 (view source)

Usage:
  • (reduce-augmented r coll)

  • (reduce-augmented r init coll)

Type signatures:
  • (IReducing ⨯ IRed) → Any

  • (IReducing ⨯ Any ⨯ IRed) → Any

Returns a result of the reduction of coll with the augmented reducing function r and with initial value init, which defaults to (-init r). May return postponed object.

reduce-one-augmented

Available since version 1.0 (view source)

Usage:
  • (reduce-one-augmented r item)

  • (reduce-one-augmented r init item)

Type signatures:
  • (IReducing ⨯ Any) → Any

  • (IReducing ⨯ Any ⨯ Any) → Any

Returns a result of the reduction of one item with the augmented reducing function r and with initial value init, which defaults to (-init r). May return postponed object.

reduced

Available since version 1.0 (alias of clojure.core/reduced)

Usage:
  • (reduced x)

Type signature:
  • (Any) → Reduced

Returns a reduced object which holds a reference to the x. Is used for early termination of a reduction.

reduced?

Available since version 1.0 (view source)

Usage:
  • (reduced? x)

Type signature: Predicate

Returns true if object x is an instance of Reduced type, false otherwise.

See also: Reduced, reduced

reducing

Available since version 1.0 (view source)

Usage:
  • (reducing reducef)

  • (reducing reducef init)

Type signatures:
  • (AnyFn) → IReducing

  • (AnyFn ⨯ Any) → IReducing

Returns an augmented reducing function which uses reducef for reducing steps and init for an initial value, without fold support. Uses (reducef) as an initial value if init is not supplied.

second

Available since version 1.0 (view source)

Usage:
  • (second coll)

Type signature:
  • ([]) → Any

Returns the second item of the collection coll, or nil if coll is nil or has less than two items.

See also: first, rest, next, seq

sequential?

Available since version 1.0 (view source)

Usage:
  • (sequential? x)

Type signature:
  • (Any) → Boolean+

Returns true if x is a sequential collection as defined by the ISequential protocol, or if x is a host sequential collection. Returns false otherwise.

transduce

Available since version 1.0 (view source)

Usage:
  • (transduce xform reducef coll)

  • (transduce xform reducef init coll)

Type signatures:
  • (AnyFn ⨯ AnyFn ⨯ IRed) → Any

  • (AnyFn ⨯ AnyFn ⨯ Any ⨯ IRed) → Any

Returns a result of the reduction of coll with the classic reducing function reducef, initial value init (which defaults to (reducef) if not provided), and transducer xform. May return a postponed result.

transduce-one

Available since version 1.0 (view source)

Usage:
  • (transduce-one xform reducef item)

  • (transduce-one xform reducef init item)

Type signatures:
  • (AnyFn ⨯ AnyFn ⨯ Any) → Any

  • (AnyFn ⨯ AnyFn ⨯ Any ⨯ Any) → Any

Returns a result of the reduction of one item with the classic reducing function reducef, initial value init (which defaults to (reducef) if not provided, and transducer xform. May return a postponed result.

unsafe-advance!

Available since version 1.0 (view source)

Usage:
  • (unsafe-advance! postponed)

Type signature:
  • (Postponed) → Any

Continues with the reduction of a postponed result and returns the reduced result, applying same rules as in the reduce function. May again return another postponed object. It is not safe to call this function more than once on a same postponed object. Use advance function for that.

unsafe-postponed

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (unsafe-postponed ret uadvancef)

Type signature:
  • (Any ⨯ AnyFn) → Postponed

Returns a postponed reference to the intermediate result ret, with uadvancef as a function that continues the reduction in an unsafe way (one call to unsafe-advance! per object only), and which defaults to (constantly ret). The caller can get the intermediate result by dereferencing the returned object. The reduction is continued by calling unsafe-advance! function.

when-first

Available since version 1.0 (view source)

MACRO (when-first bindings & body)

bindings ⇒ x xs

Roughly the same as (when (seq xs) (let [x (first xs)] body)) but xs is evaluated only once.

See also: first

Seqs

In this section: next nnext nthnext nthrest rest seq seq?

next

Available since version 1.0 (view source)

Usage:
  • (next coll)

Type signature:
  • ([]) → (Maybe ISeq)

Returns a seq of the items after the first. Calls seq on coll. If there are no more items, returns nil.

See also: rest, nthnext, first

nnext

Available since version 1.0 (view source)

Usage:
  • (nnext coll)

Type signature:
  • ([]) → (Maybe ISeq)

Returns a seq of the items after the second. Calls seq on coll. If there are no more items, returns nil.

See also: rest, next, nthnext

nthnext

Available since version 1.0 (alias of clojure.core/nthnext)

Usage:
  • (nthnext coll n)

Type signature:
  • ([] ⨯ Integer+) → (Maybe ISeq)

Returns the n-th next of coll, or returns (seq coll) when n is 0.

See also: nthrest, next, nnext, first, seq

nthrest

Available since version 1.0 (alias of clojure.core/nthrest)

Usage:
  • (nthrest coll n)

Type signature:
  • ([] ⨯ Integer+) → ISeq

Returns the n-th rest of coll, or returns coll when n is 0.

See also: nthnext, rest, first, seq

rest

Available since version 1.0 (alias of clojure.core/rest)

Usage:
  • (rest coll)

Type signature:
  • ([]) → ISeq

Returns a possibly empty seq of the items after the first. Calls seq on coll.

See also: next, nthrest, first

seq

Available since version 1.0 (alias of clojure.core/seq)

Usage:
  • (seq coll)

Type signatures:
  • (nil) → nil

  • (IRed) → (Maybe ISeq)

Returns a seq on the collection coll. If the collection is empty, returns nil. (seq nil) returns nil. seq works on any collection.

seq?

Available since version 1.0 (view source)

Usage:
  • (seq? x)

Type signature: Predicate

Returns true if object x satisfies ISeq protocol, false otherwise.

See also: ISeq, rest

Features

ascending?

Available since version 1.0 (view source)

Usage:
  • (ascending? coll)

Type signature:
  • (ISorted) → Boolean+

Returns true if coll is sorted in ascending order, otherwise returns false. Throws if collection is not sorted.

brimming?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (brimming? coll)

Type signature:
  • ([]) → Boolean+

Returns true if coll is capped and the number of items in it equals to its capacity, otherwise returns false. Note that this is not equal to calling full?, as full? additionally indicates that collection does not accepts any more items. Conjoining a brimming collection is dependent on the collection type. Examples include throwing (fixed buffer), ignoring the new item (dropping buffer), dropping oldest item (sliding buffer) or increase its capacity (transient string).

See also: full?, capacity, count

capacity

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (capacity coll)

Type signature:
  • (ICapped) → Integer+

Returns capacity of a given capped coll.

See also: brimming?, count, capped?, full?

capped?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (capped? x)

Type signature: Predicate

Returns true if object x satisfies ICapped protocol, false otherwise.

See also: ICapped, capacity, brimming?

contains?

Available since version 1.0 (view source)

Usage:
  • (contains? coll key)

Type signature:
  • ((Maybe ILookup) ⨯ Any) → Boolean+

Returns true if coll contains entry with a given key. Returns false if coll is nil.

See also: get, lookup?, nth

count

Available since version 1.0 (view source)

Usage:
  • (count coll)

Type signature:
  • ([]) → Integer+

Returns the size of a collection coll.

counted?

Available since version 1.0 (view source)

Usage:
  • (counted? x)

Type signature: Predicate

Returns true if object x satisfies ICounted protocol, false otherwise.

double?

Available since version 1.0 (view source)

Usage:
  • (double? coll)

Type signature:
  • ([]) → Boolean+

Returns true if coll contains exactly two items, returns false otherwise.

edit

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (edit coll)

  • (edit coll capacity-hint)

Type signatures:
  • (IEditable) → Any

  • (IEditable ⨯ (Maybe Integer+)) → Any

Returns the mutable collection based on coll. This operation is (amortized) constant time if coll is a persistent collection. Throws if coll is not editable.

See also: settle!, editable?

editable?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (editable? x)

Type signature: Predicate

Returns true if object x satisfies IEditable protocol, false otherwise.

See also: IEditable, edit, settle!

empty

Available since version 1.0 (view source)

Usage:
  • (empty coll)

Type signature:
  • ([]) → []

Returns an empty collection of the same category as coll, or nil if coll is not emptyable. Metadata is preserved.

empty?

Available since version 1.0 (view source)

Usage:
  • (empty? coll)

Type signature:
  • ([]) → Boolean+

Returns true if coll is nil or has no items, returns false otherwise.

emptyable?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (emptyable? x)

Type signature: Predicate

Returns true if object x satisfies IEmptyable protocol, false otherwise.

See also: IEmptyable, empty

flip

Available since version 1.0 (view source)

Usage:
  • (flip coll)

Type signature:
  • (IFlippable) → IFlippable

Returns flipped collection from coll in better than linear time. Returned collection is of the same type as coll. Throws if collection is not reversible. Should be used when collection type has to be preserved, which is not very often. Supported mainly in sorted collections. Use reverse if you are OK with collection of a different type. Use revlist if any of above fails.

flippable?

Available since version 1.0 (view source)

Usage:
  • (flippable? x)

Type signature: Predicate

Returns true if object x satisfies IFlippable protocol, false otherwise.

See also: IFlippable, flip

full-aware?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (full-aware? x)

Type signature: Predicate

Returns true if object x satisfies IFullAware protocol, false otherwise.

See also: IFullAware, capped?

full?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (full? coll)

Type signature:
  • (Any) → Boolean+

Returns true if coll satisfies IFullAware protocol and is full, otherwise returns false. Full collections (usually) don’t accept new items and they throw on conj.

get

Available since version 1.0 (view source)

Usage:
  • (get coll key)

  • (get coll key not-found)

Type signatures:
  • (Any ⨯ Any) → Any

  • (Any ⨯ Any ⨯ Any) → Any

Returns item for a given key, or returns not-found if item is not found. Returns not-found also if coll does not support ILookup. If not-found is not supplied and item is not found, returns nil. Returns collection implementing ICounted, if there are multiple values for a given key (e.g. in multimap or bag).

See also: contains?, lookup?, nth, get-in

get-in

Available since version 1.0 (view source)

Usage:
  • (get-in m ks)

  • (get-in m ks not-found)

Type signatures:
  • (Any ⨯ [Any]) → Any

  • (Any ⨯ [Any] ⨯ Any) → Any

Returns the value in a nested associative structure, where ks is a sequence of keys. Returns nil if the key is not present, or the not-found value if supplied.

See also: get, nth, contains?, lookup?

homogeneous?

Available since version 1.0 (view source)

Usage:
  • (homogeneous? x)

Type signature: Predicate

Returns true if object x satisfies IHomogeneous protocol, false otherwise.

See also: IHomogeneous, item-type

indexed?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (indexed? x)

Type signature: Predicate

Returns true if object x satisfies IIndexed protocol, false otherwise.

See also: IIndexed, nth

invert

Available since version 1.0 (view source)

Usage:
  • (invert coll)

Type signature:
  • (IInvertible) → IInvertible

Returns inverted collection from coll in better than linear time. Example of such collection is set or bimap.

invertible?

Available since version 1.0 (view source)

Usage:
  • (invertible? x)

Type signature: Predicate

Returns true if object x satisfies IInvertible protocol, false otherwise.

See also: IInvertible, invert

item-type

Available since version 1.0 (view source)

Usage:
  • (item-type coll)

Type signature:
  • (IHomogeneous) → (U nil Class+ Type)

Returns type of items in coll homogeneous collection. Returns nil if coll can produce items of any requested type. Throws if coll is not homogeneous.

lookup?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (lookup? x)

Type signature: Predicate

Returns true if object x satisfies ILookup protocol, false otherwise.

See also: ILookup, contains?, get

not-empty

Available since version 1.0 (view source)

Usage:
  • (not-empty coll)

Type signature:
  • ([]) → []

If coll is empty, returns nil, else coll.

not-empty?

Available since version 1.0 (view source)

Usage:
  • (not-empty? coll)

Type signature:
  • ([]) → Boolean+

Returns true if coll is not empty, returns false otherwise.

nth

Available since version 1.0 (view source)

Usage:
  • (nth coll index)

  • (nth coll index not-found)

Type signatures:
  • ([] ⨯ Integer+) → Any

  • ([] ⨯ Integer+ ⨯ Any) → Any

Returns item at index position, or returns not-found if position is out of bounds. Throws an exception if not-found is not supplied, coll is not nil and item is not found. Returns nil (or not-found) if coll is nil.

See also: get, get-in, contains?, indexed?

peek

Available since version 1.0 (view source)

Usage:
  • (peek coll)

Type signature:
  • ((Maybe IPeekable)) → Any

Returns item from a collection coll at a position specified by the implementation. It may be the first item (Lists, Queues), or it may be the last item (Vector). Returns nil if coll is nil or empty.

peekable?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (peekable? x)

Type signature: Predicate

Returns true if object x satisfies IPeekable protocol, false otherwise.

See also: IPeekable, peek

quad?

Available since version 1.0 (view source)

Usage:
  • (quad? coll)

Type signature:
  • ([]) → Boolean+

Returns true if coll contains exactly four items, returns false otherwise.

quint?

Available since version 1.0 (view source)

Usage:
  • (quint? coll)

Type signature:
  • (IRed) → Boolean+

Returns true if coll contains exactly five items, returns false otherwise.

reverse

Available since version 1.0 (view source)

Usage:
  • (reverse coll)

Type signature:
  • (IReversible) → IRed

Returns a collection with reverse order of items, in constant time. Throws if coll is not reversible. Use flip if you need to preserve type. Use revlist for collections which are not reversible nor flippable.

reversible?

Available since version 1.0 (view source)

Usage:
  • (reversible? x)

Type signature: Predicate

Returns true if object x satisfies IReversible protocol, false otherwise.

See also: IReversible, reverse

section

Available since version 1.0 (view source)

Usage:
  • (section coll begin)

  • (section coll begin end)

Type signatures:
  • (ISectionable ⨯ Any) → []

  • (ISectionable ⨯ Any ⨯ Any) → []

Returns new collection which is the result of sectioning coll from begin inclusive into the end exclusive. nil in begin defaults to the first item and nil in the end defaults to the last item in the coll. Resulting coll will be of similar type but will share underlying data with original coll and thus will hold onto all original items. Operation is constant time though. begin and end may be numbers for indexed collections and arbitrary objects for e.g. sorted sets or maps. Note that section of some types is not persistent. This fn is the replacement for all c.c/subs, subvec, subseq …​

sectionable?

Available since version 1.0 (view source)

Usage:
  • (sectionable? x)

Type signature: Predicate

Returns true if object x satisfies ISectionable protocol, false otherwise.

See also: ISectionable, section

several?

Available since version 1.0 (view source)

Usage:
  • (several? coll)

Type signature:
  • ([]) → Boolean+

Returns true if coll contains more than one item, returns false otherwise.

See also: count, single?, empty?

single?

Available since version 1.0 (view source)

Usage:
  • (single? coll)

Type signature:
  • ([]) → Boolean+

Returns true if coll contains exactly one item, returns false otherwise.

See also: count, several?, double?, empty?

slice

Available since version 1.0 (view source)

Usage:
  • (slice coll begin)

  • (slice coll begin end)

Type signatures:
  • (ISliceable ⨯ Any) → ISliceable

  • (ISliceable ⨯ Any ⨯ Any) → ISliceable

Returns new collection which is the result of slicing coll from begin inclusive into the end exclusive. nil in begin defaults to the first item and nil in the end defaults to the last item in the coll. Resulting coll will be of same type and will not hold onto items not belonging to it. Operation is better than linear time.

See also: section, sliceable?

sliceable?

Available since version 1.0 (view source)

Usage:
  • (sliceable? x)

Type signature: Predicate

Returns true if object x satisfies ISliceable protocol, false otherwise.

See also: ISliceable, slice

sorted-sectionable?

Available since version 1.0 (view source)

Usage:
  • (sorted-sectionable? x)

Type signature: Predicate

Returns true if object x satisfies ISortedSectionable protocol, false otherwise.

sorted?

Available since version 1.0 (view source)

Usage:
  • (sorted? x)

Type signature: Predicate

Returns true if object x satisfies ISorted protocol, false otherwise.

See also: ISorted, ascending?

triple?

Available since version 1.0 (view source)

Usage:
  • (triple? coll)

Type signature:
  • ([]) → Boolean+

Returns true if coll contains exactly three items, returns false otherwise.

Persistent

assoc

Available since version 1.0 (view source)

Usage:
  • (assoc)

  • (assoc coll)

  • (assoc coll key val)

  • (assoc coll key1 val1 key2 val2)

  • (assoc coll key1 val1 key2 val2 key3 val3)

  • (assoc coll key1 val1 key2 val2 key3 val3 key4 val4)

  • (assoc coll key1 val1 key2 val2 key3 val3 key4 val4 & keyvals)

Type signatures:
  • () → IAssociative

  • ((Maybe IAssociative)) → IAssociative

  • ((Maybe IAssociative) ⨯ Any ⨯ Any) → IAssociative

  • ((Maybe IAssociative) ⨯ Any ⨯ Any ⨯ Any ⨯ Any) → IAssociative

  • ((Maybe IAssociative) ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any) → IAssociative

  • ((Maybe IAssociative) ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any) → IAssociative

  • ((Maybe IAssociative) ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ (Va Any)) → IAssociative

assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index. Note - index must be <= (count vector). If coll is nil, empty map will be used instead. For multimap, val must be a collection and this method replaces all previous vals with those in val.

assoc-in

Available since version 1.0 (alias of clojure.core/assoc-in)

Usage:
  • (assoc-in m [k & ks] v)

Type signature:
  • ((Maybe IAssociative) ⨯ IRed ⨯ Any) → IAssociative

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. If any levels do not exist, maps will be created.

associative?

Available since version 1.0 (view source)

Usage:
  • (associative? x)

Type signature: Predicate

Returns true if object x satisfies IAssociative protocol, false otherwise.

See also: IAssociative, assoc

bag?

Available since version 1.0 (view source)

Usage:
  • (bag? x)

Type signature: Predicate

Returns true if object x satisfies IPersistentBag protocol, false otherwise.

cat

Available since version 1.0 (view source)

Usage:
  • (cat coll other)

Type signature:
  • (ICatenable ⨯ ICatenable) → ICatenable

Returns the catenation of coll with other collection of same type. Resulting collection is of the same type. Operation is faster than linear time.

catenable?

Available since version 1.0 (view source)

Usage:
  • (catenable? x)

Type signature: Predicate

Returns true if object x satisfies ICatenable protocol, false otherwise.

See also: ICatenable, cat

coll?

Available since version 1.0 (view source)

Usage:
  • (coll? x)

Type signature: Predicate

Returns true if object x directly implements IPersistentCollection protocol, false otherwise.

conj

Available since version 1.0 (view source)

Usage:
  • (conj)

  • (conj coll)

  • (conj coll x)

  • (conj coll x1 x2)

  • (conj coll x1 x2 x3)

  • (conj coll x1 x2 x3 x4)

  • (conj coll x1 x2 x3 x4 x5)

  • (conj coll x1 x2 x3 x4 x5 & more)

Type signatures:
  • () → IPersistentCollection

  • ((Maybe IPersistentCollection)) → IPersistentCollection

  • ((Maybe IPersistentCollection) ⨯ Any) → IPersistentCollection

  • ((Maybe IPersistentCollection) ⨯ Any ⨯ Any) → IPersistentCollection

  • ((Maybe IPersistentCollection) ⨯ Any ⨯ Any ⨯ Any) → IPersistentCollection

  • ((Maybe IPersistentCollection) ⨯ Any ⨯ Any ⨯ Any ⨯ Any) → IPersistentCollection

  • ((Maybe IPersistentCollection) ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any) → IPersistentCollection

  • ((Maybe IPersistentCollection) ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ (Va Any)) → IPersistentCollection

Returns coll with given items conjoined. Conjoins into empty list if coll is nil.

disj

Available since version 1.0 (view source)

Usage:
  • (disj coll)

  • (disj coll key)

  • (disj coll key & keys)

Type signatures:
  • ((Maybe IPersistentSet)) → (Maybe IPersistentSet)

  • ((Maybe IPersistentSet) ⨯ Any) → (Maybe IPersistentSet)

  • ((Maybe IPersistentSet) ⨯ Any ⨯ (Va Any)) → (Maybe IPersistentSet)

Returns the coll with key removed. For bags, only one instance of key is removed. Returns nil if coll is nil.

See also: dissoc, disj-all, disj!, set?

disj-all

Available since version 1.0 (view source)

Usage:
  • (disj-all coll key)

Type signature:
  • ((Maybe IPersistentBag) ⨯ Any) → (Maybe IPersistentBag)

Returns the coll with all instances of key removed. Returns nil if coll is nil.

See also: dissoc, disj, disj-all!, bag?

dissoc

Available since version 1.0 (view source)

Usage:
  • (dissoc coll)

  • (dissoc coll key)

  • (dissoc coll key1 key2)

  • (dissoc coll key1 key2 key3)

  • (dissoc coll key1 key2 key3 & ks)

Type signatures:
  • ((Maybe IPersistentMap)) → (Maybe IPersistentMap)

  • ((Maybe IPersistentMap) ⨯ Any) → (Maybe IPersistentMap)

  • ((Maybe IPersistentMap) ⨯ Any ⨯ Any) → (Maybe IPersistentMap)

  • ((Maybe IPersistentMap) ⨯ Any ⨯ Any ⨯ Any) → (Maybe IPersistentMap)

  • ((Maybe IPersistentMap) ⨯ Any ⨯ Any ⨯ Any ⨯ (Va Any)) → (Maybe IPersistentMap)

dissoc[iate]. Returns a new coll that does not contain any mapping for key. Returns nil if coll is nil.

dissoc-in

Available since version 1.0 (view source)

Usage:
  • (dissoc-in m [k & ks])

Type signature:
  • ((Maybe IPersistentMap) ⨯ Any) → (Maybe IPersistentMap)

Dissociates a value in a nested associative structure, where ks is a sequence of keys and returns a new nested structure.

See also: map?, dissoc, dissoc-one, dissoc!

dissoc-one

Available since version 1.0 (view source)

Usage:
  • (dissoc-one coll key val)

Type signature:
  • ((Maybe IPersistentMultiMap) ⨯ Any ⨯ Any) → IPersistentMultiMap

dissoc[iate]. Returns a new coll that does not contain [key val] mapping. Returns nil if coll is nil.

hit

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (hit coll key)

Type signature:
  • ([] ⨯ Any) → (Maybe IUsageTracking)

Returns a collection which has processed a hit (usage) notification of a value associated with key. Undefined behavior if coll does not contain mapping for key. Returns the same collection if it does not implement usage tracking. Returns nil if coll is nil.

See also: usage-tracking?

list?

Available since version 1.0 (view source)

Usage:
  • (list? x)

Type signature: Predicate

Returns true if object x satisfies IPersistentList protocol, false otherwise.

See also: IPersistentList

map?

Available since version 1.0 (view source)

Usage:
  • (map? x)

Type signature: Predicate

Returns true if object x satisfies IPersistentMap protocol, false otherwise.

See also: IPersistentMap, dissoc

multimap?

Available since version 1.0 (view source)

Usage:
  • (multimap? x)

Type signature: Predicate

Returns true if object x satisfies IPersistentMultiMap protocol, false otherwise.

pop

Available since version 1.0 (view source)

Usage:
  • (pop coll)

Type signature:
  • ((Maybe IStacked)) → (Maybe IStacked)

Returns coll without one item at a position specified by the implementation. It may be the first item (Lists, Queues), or it may be the last item (Vector). Returns nil if coll is nil. Throws if coll is empty.

set?

Available since version 1.0 (view source)

Usage:
  • (set? x)

Type signature: Predicate

Returns true if object x satisfies IPersistentSet protocol, false otherwise.

See also: IPersistentSet, disj

stacked?

Available since version 1.0 (view source)

Usage:
  • (stacked? x)

Type signature: Predicate

Returns true if object x satisfies IStacked protocol, false otherwise.

See also: IStacked, pop

update

Available since version 1.0 (alias of clojure.core/update)

Usage:
  • (update m k f)

  • (update m k f x)

  • (update m k f x y)

  • (update m k f x y z)

  • (update m k f x y z & more)

Type signature:
  • ((Maybe IAssociative) ⨯ AnyFn ⨯ (Va Any)) → IAssociative

'Updates' a value in an associative structure, where k is a key and f is a function that will take the old value and any supplied args and return the new value, and returns a new structure. If the key does not exist, nil is passed as the old value.

update-in

Available since version 1.0 (alias of clojure.core/update-in)

Usage:
  • (update-in m [k & ks] f & args)

Type signature:
  • ((Maybe IAssociative) ⨯ IRed ⨯ AnyFn ⨯ (Va Any)) → IAssociative

'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. If any levels do not exist, maps will be created.

See also: update, assoc, assoc-in

usage-tracking?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (usage-tracking? x)

Type signature: Predicate

Returns true if object x satisfies IUsageTracking protocol, false otherwise.

See also: IUsageTracking, hit

vector?

Available since version 1.0 (view source)

Usage:
  • (vector? x)

Type signature: Predicate

Returns true if object x satisfies IPersistentVector protocol, false otherwise.

See also: IPersistentVector

Mutable

assoc!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (assoc! coll)

  • (assoc! coll key val)

  • (assoc! coll key val & kvs)

Type signatures:
  • (IMutableAssociative) → IMutableAssociative

  • (IMutableAssociative ⨯ Any ⨯ Any) → IMutableAssociative

  • (IMutableAssociative ⨯ Any ⨯ Any ⨯ (Va Any)) → IMutableAssociative

When applied to a mutable map, adds mapping of key(s) to val(s). When applied to a mutable vector, sets the val at index. Note that index must be <= (count vector). Do not use original coll after this call, but use returned collection instead.

See also: assoc, edit, settle!, conj!, pop!

cat!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (cat! coll other)

Type signature:
  • (IMutableCatenable ⨯ IMutableCatenable) → IMutableCatenable

Returns the catenation of coll with other collection of similar type. Resulting collection is of the same type. Operation is faster than linear time. Do not use original coll after this call, but use returned collection instead.

conj!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (conj! coll)

  • (conj! coll x)

  • (conj! coll x y)

  • (conj! coll x y z)

  • (conj! coll x y z a)

  • (conj! coll x y z a & more)

Type signatures:
  • (IMutableCollection) → IMutableCollection

  • (IMutableCollection ⨯ Any) → IMutableCollection

  • (IMutableCollection ⨯ Any ⨯ Any) → IMutableCollection

  • (IMutableCollection ⨯ Any ⨯ Any ⨯ Any) → IMutableCollection

  • (IMutableCollection ⨯ Any ⨯ Any ⨯ Any ⨯ Any) → IMutableCollection

  • (IMutableCollection ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ (Va Any)) → IMutableCollection

Returns coll with items conjoined. Mutates coll. Do not use original coll after this call, but use returned collection instead.

See also: conj, edit, settle!, assoc!, pop!

disj!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (disj! coll)

  • (disj! coll key)

  • (disj! coll key & ks)

Type signatures:
  • (IMutableSet) → IMutableSet

  • (IMutableSet ⨯ Any) → IMutableSet

  • (IMutableSet ⨯ Any ⨯ (Va Any)) → IMutableSet

Returns the coll with key removed. For bags, only one instance of key is removed. Do not use original coll after this call, but use returned collection instead.

See also: disj, disj-all!

disj-all!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (disj-all! coll key)

Type signature:
  • (IMutableBag ⨯ Any) → IMutableBag

Returns the coll with all instances of key removed. Do not use original coll after this call, but use returned collection instead.

See also: disj!, disj-all

dissoc!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (dissoc! coll)

  • (dissoc! coll key)

  • (dissoc! coll key & ks)

Type signatures:
  • (IMutableMap) → IMutableMap

  • (IMutableMap ⨯ Any) → IMutableMap

  • (IMutableMap ⨯ Any ⨯ (Va Any)) → IMutableMap

dissoc[iate]. Returns a new coll that does not contain any mapping for key. Do not use original coll after this call, but use returned collection instead.

See also: dissoc, dissoc-one!

dissoc-one!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (dissoc-one! coll key val)

Type signature:
  • (IMutableMultiMap ⨯ Any ⨯ Any) → IMutableMultiMap

dissoc[iate]. Returns a new coll that does not contain mapping specified by key and val. Do not use original coll after this call, but use returned collection instead.

See also: dissoc-one, dissoc!

pop!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (pop! coll)

Type signature:
  • (IMutableStacked) → IMutableStacked

Returns coll without one item at a position specified by the implementation. It may be the first item (Lists, Queues), or it may be the last item (Vector). Do not use original coll after this call, but use returned collection instead.

See also: pop, edit, settle!, conj!, assoc!

settle!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (settle! coll)

Type signature:
  • (ISettleable) → IRed

Returns the immutable version of a mutable coll. Any subsequent operations on original coll will throw.

See also: edit, settleable?, snapshot!

settleable?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (settleable? x)

Type signature: Predicate

Returns true if object x satisfies ISettleable protocol, false otherwise.

See also: ISettleable, settle!

snapshot!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (snapshot! coll)

Type signature:
  • (ISnapshotable) → IRed

Returns the immutable or persistent snapshot of coll. Both coll and the returned object can be further freely used. Mutable snapshots (if supported) are performed with clone.

snapshotable?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (snapshotable? x)

Type signature: Predicate

Returns true if object x satisfies ISnapshotable protocol, false otherwise.

Factory

→collection

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (->collection factory)

  • (->collection factory a)

  • (->collection factory a b)

  • (->collection factory a b c)

  • (->collection factory a b c d)

  • (->collection factory a b c d & more)

Type signatures:
  • (ICollectionFactory) → IRed

  • (ICollectionFactory ⨯ Any) → IRed

  • (ICollectionFactory ⨯ Any ⨯ Any) → IRed

  • (ICollectionFactory ⨯ Any ⨯ Any ⨯ Any) → IRed

  • (ICollectionFactory ⨯ Any ⨯ Any ⨯ Any ⨯ Any) → IRed

  • (ICollectionFactory ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ (Va Any)) → IRed

Returns a new collection created by factory which will contain given items, if any.

→convolution

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (->convolution factory)

  • (->convolution factory a b)

  • (->convolution factory a b c)

  • (->convolution factory a b c d)

  • (->convolution factory a b c d e)

  • (->convolution factory a b c d e f)

  • (->convolution factory a b c d e f g)

  • (->convolution factory a b c d e f g h)

  • (->convolution factory a b c d e f g h & more)

Type signatures:
  • (IConvolutionFactory) → IRed

  • (IConvolutionFactory ⨯ Any ⨯ Any) → IRed

  • (IConvolutionFactory ⨯ Any ⨯ Any ⨯ Any) → IRed

  • (IConvolutionFactory ⨯ Any ⨯ Any ⨯ Any ⨯ Any) → IRed

  • (IConvolutionFactory ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any) → IRed

  • (IConvolutionFactory ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any) → IRed

  • (IConvolutionFactory ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any) → IRed

  • (IConvolutionFactory ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any) → IRed

  • (IConvolutionFactory ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ (Va Any)) → IRed

Returns new collection from given interleaved pieces, if any.

collection

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (collection factory coll)

Type signature:
  • (ICollectionFactory ⨯ []) → IRed

Returns a new collection created by factory that will contain same contents as collection coll, which can also be nil.

convolution

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (convolution factory c1 c2)

  • (convolution factory c1 c2 c3)

  • (convolution factory c1 c2 c3 c4)

  • (convolution factory c1 c2 c3 c4 & more)

Type signatures:
  • (IConvolutionFactory ⨯ Any ⨯ Any) → IRed

  • (IConvolutionFactory ⨯ Any ⨯ Any ⨯ Any) → IRed

  • (IConvolutionFactory ⨯ Any ⨯ Any ⨯ Any ⨯ Any) → IRed

  • (IConvolutionFactory ⨯ Any ⨯ Any ⨯ Any ⨯ Any ⨯ (Va Any)) → IRed

Returns a new collection which will contain convoluted contents from given collections. Used e.g. for maps.