Emacs Lisp: Sequence Type
Here's a hierachy chart of elisp's most important list-like datatypes.
Note: “Sequence” and “Array” are not actual datatypes in elisp. They are grouping names for other actual datatypes.
List and Vector both hold a ordered sequence of values, each value can be any type.
Differences Between List and Vector
Here's the primary differences between List and Vector:
- List, access time to nth element is proportional to size of n.
- List's length can grow by prepending element, and can shorten by removing first element. These operations have constant time.
- 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)
In short, list can grow or shorten, but if you have a long list, say 1 thousand items, getting the value of 900th item is slow.
Vector has fixed length. Getting the value of any element is fast.
Lisp Data Structure
- Cons Pair
- Quote and Dot Notation
- Proper List
- Create List
- List, Get Elements
- Modify List
- Check Element Exist in List
- Remove Elements in List
- Backquote Reader Macro