Next: Array Functions Prev: Sequence Functions Up: Sequences Arrays Vectors


   An "array" object refers directly to a number of other Lisp objects,
called the elements of the array.  Any element of an array may be
accessed in constant time.  In contrast, an element of a list requires
access time that is proportional to the position of the element in the

   When you create an array, you must specify how many elements it has.
The amount of space allocated depends on the number of elements.
Therefore, it is impossible to change the size of an array once it is
created.  You cannot add or remove elements.  However, you can replace
an element with a different value.

   Emacs defines two types of array, both of which are one-dimensional:
"strings" and "vectors".  A vector is a general array; its elements can
be any Lisp objects.  A string is a specialized array; its elements
must be characters (i.e., integers between 0 and 255).  Each type of
array has its own read syntax.  Note: String Type, and Note: Vector

   Both kinds of arrays share these characteristics:

   * The first element of an array has index zero, the second element
     has index 1, and so on.  This is called "zero-origin" indexing.
     For example, an array of four elements has indices 0, 1, 2, and 3.

   * The elements of an array may be referenced or changed with the
     functions `aref' and `aset', respectively (Note: Array

   In principle, if you wish to have an array of characters, you could
use either a string or a vector.  In practice, we always choose strings
for such applications, for four reasons:

   * They occupy one-fourth the space of a vector of the same elements.

   * Strings are printed in a way that shows the contents more clearly
     as characters.

   * Strings can hold text properties.  Note: Text Properties.

   * Many of the specialized editing and I/O facilities of Emacs accept
     only strings.  For example, you cannot insert a vector of
     characters into a buffer the way you can insert a string.  *Note
     Strings and Characters::.

automatically generated by info2www