Elisp: Sequence: List, Array
Here's a chart of elisp's most important list-like datatypes.
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,
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:
- Vector: Access time to any element is constant.
- Vector's length cannot change. (if you create a new copy of a vector, the time required is proportional to the vector's length)
- List: Access time to a element is proportional to the distance of the element's position in the list.
- 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))