Clojure collection quirks - A REFERENCE


This is a reference of Clojure’s default data structures and the most common predicates.

Functions

This table contains the most common predicates applied to the core collections.

SeqVectorMapSet
nil'(1 2 3)(range 5)(range)
(lazy-seq)
(cons 1 ())
Persistent
Queue/EMPTY
[1 2 3](last {1 1})(hash-map)
(array-map)
(sorted-map)#{}(sorted-set)
typenilPersistent
List
LongRangeIterate
or LazySeq
or Cons
Persistent
Queue
Persistent
Vector
MapEntryPersistent
ArrayMap
or HashMap
Persistent
TreeMap
Persistent
HashSet
Persistent
TreeSet
coll?falsetruetruetruetruetruetruetruetruetruetrue
counted?falsetruetruefalsetruetruetruetruetruetruetrue
ifn?falsefalsefalsefalsefalsetruetruetruetruetruetrue
associative?falsefalsefalsefalsefalsetruetruetruetruefalsefalse
map?falsefalsefalsefalsefalsefalsefalsetruetruefalsefalse
sequential?falsetruetruetruetruetruetruefalsefalsefalsefalse
list?falsetruefalsefalsetruefalsefalsefalsefalsefalsefalse
seq?falsetruetruetruefalsefalsefalsefalsefalsefalsefalse
reversible?falsefalsefalsefalsefalsetruetruefalsetruefalsetrue
vector?falsefalsefalsefalsefalsetruetruefalsefalsefalsefalse
map-entry?falsefalsefalsefalsefalsefalsetruefalsefalsefalsefalse
map?falsefalsefalsefalsefalsefalsefalsetruetruefalsefalse
set?falsefalsefalsefalsefalsefalsefalsefalsefalsetruetrue
sorted?falsefalsefalsefalsefalsefalsefalsefalsetruefalsetrue


Interfaces

An incomplete list of some of the most commonly used default Clojure interfaces found in the clojure.lang package.

IMeta

The object has meta information accessible via the (meta x) function.

IObj

Indicates that meta information can be added to object (with-meta function).

Counted

This collection supports fast counting ((count x) function call).

IEditableCollection

A transient version of the collection can be created with the (transient x) call.

IFn

Indicates that he object can be called just like a function.

IKeywordLookup

A collection supports indexing by keywords.

ILookup

Collection supports access by index (via get function with default value).

IPending

Supports realized? function.

IPersistentCollection

Persistent collections have support for conj, empty, count, equals functions.

ISeq

Sequences have support for first, next, rest, cons functions.