Elisp: Sequence: List, Array

By Xah Lee. Date: . Last updated: .

Here's a chart of elisp's most important list-like datatypes.

emas lisp data structure
Most commonly used list-like data structure in elisp. (note: there's also char-table and bool-vector datatypes, which are sub-types of of array type. They are more specialized/advanced.)

Note: Sequence is not a actual datatype in elisp. Array is not a actual datatype in elisp. They are just grouping names.

When a function's doc says an argument is a sequence type, it means that it can be list, vector, or string, e.g. {mapcar, length, elt}.

When a function's doc says an argument is a array type, it means that it can be vector, or string,

List and Vector both holds a sequence of values, each value can be any type.

Here's the primary differences between list and vector:

  1. Vector: Access time to any element is constant.
  2. Vector's length cannot change. (if you create a new copy of a vector, the time required is proportional to the vector's length)
  1. List: Access time to a element is proportional to the distance of the element's position in the list.
  2. List's length can grow by prepending with cons, and can have the first element dropped by cdr. These operations have constant time.

[see Elisp: Vector]

[see Elisp: List]

You can nest list/vector in any way. Example:

;; vector containing list and vector
[ (f 5) [4 2]]

;; list containing list and vector
'( [8 7] (b 1))

(info "(elisp) Sequences Arrays Vectors")

Data Structure Topic

  1. Elisp: Sequence: List, Array
  2. Elisp: Vector
  3. Elisp: List
  4. Elisp: Association List
  5. Elisp: Property List
  6. Elisp: Symbol Property List
  7. Elisp: Map / Loop Thru List / Vector
  8. Elisp: Filter a List
  9. Elisp: Hash Table
Like my tutorial? Put $5 at patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboard for Emacs