Mercurial > emacs
diff lispref/sequences.texi @ 7119:19bd3bfc57de
entered into RCS
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Tue, 26 Apr 1994 22:21:24 +0000 |
| parents | 71e61b314fe9 |
| children | 73dc8205d259 |
line wrap: on
line diff
--- a/lispref/sequences.texi Tue Apr 26 22:08:09 1994 +0000 +++ b/lispref/sequences.texi Tue Apr 26 22:21:24 1994 +0000 @@ -13,33 +13,33 @@ common property that all sequences have is that each is an ordered collection of elements. - An @dfn{array} is a single primitive object directly containing all -its elements. Therefore, all the elements are accessible in constant -time. The length of an existing array cannot be changed. Both strings -and vectors are arrays. A list is a sequence of elements, but it is not -a single primitive object; it is made of cons cells, one cell per -element. Therefore, elements farther from the beginning of the list -take longer to access, but it is possible to add elements to the list or -remove elements. + An @dfn{array} is a single primitive object that has a slot for each +elements. All the elements are accessible in constant time, but the +length of an existing array cannot be changed. Both strings and vectors +are arrays. + + A list is a sequence of elements, but it is not a single primitive +object; it is made of cons cells, one cell per element. Finding the +@var{n}th element requires looking through @var{n} cons cells, so +elements farther from the beginning of the list take longer to access. +But it is possible to add elements to the list, or remove elements. The following diagram shows the relationship between these types: @example @group - ___________________________________ - | | - | Sequence | - | ______ ______________________ | - | | | | | | - | | List | | Array | | - | | | | ________ _______ | | - | |______| | | | | | | | - | | | String | | Vector| | | - | | |________| |_______| | | - | |______________________| | - |___________________________________| - -@center @r{The relationship between sequences, arrays, and vectors} + ___________________________________ + | | + | Sequence | + | ______ ______________________ | + | | | | | | + | | List | | Array | | + | | | | ________ _______ | | + | |______| | | | | | | | + | | | String | | Vector| | | + | | |________| |_______| | | + | |______________________| | + |___________________________________| @end group @end example @@ -50,7 +50,8 @@ * Sequence Functions:: Functions that accept any kind of sequence. * Arrays:: Characteristics of arrays in Emacs Lisp. * Array Functions:: Functions specifically for arrays. -* Vectors:: Functions specifically for vectors. +* Vectors:: Special characteristics of Emacs Lisp vectors. +* Vector Functions:: Functions specifically for vectors. @end menu @node Sequence Functions @@ -199,7 +200,7 @@ @section Arrays @cindex array - An @dfn{array} object refers directly to a number of other Lisp + An @dfn{array} object has slots that hold 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 @@ -208,8 +209,8 @@ 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. +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: @dfn{strings} and @dfn{vectors}. A vector is a general array; its @@ -218,7 +219,7 @@ type of array has its own read syntax. @xref{String Type}, and @ref{Vector Type}. - Both kinds of arrays share these characteristics: + Both kinds of array share these characteristics: @itemize @bullet @item @@ -325,8 +326,8 @@ @end defun @defun fillarray array object -This function fills the array @var{array} with pointers to @var{object}, -replacing any previous values. It returns @var{array}. +This function fills the array @var{array} with @var{object}, so that +each element of @var{array} is @var{object}. It returns @var{array}. @example @group @@ -369,10 +370,10 @@ In Emacs Lisp, the indices of the elements of a vector start from zero and count up from there. - Vectors are printed with square brackets surrounding the elements -in their order. Thus, a vector containing the symbols @code{a}, -@code{b} and @code{c} is printed as @code{[a b c]}. You can write -vectors in the same way in Lisp input. + Vectors are printed with square brackets surrounding the elements. +Thus, a vector whose elements are the symbols @code{a}, @code{b} and +@code{a} is printed as @code{[a b a]}. You can write vectors in the +same way in Lisp input. A vector, like a string or a number, is considered a constant for evaluation: the result of evaluating it is the same vector. This does @@ -392,6 +393,9 @@ @end group @end example +@node Vector Functions +@section Functions That Operate on Vectors + Here are some functions that relate to vectors: @defun vectorp object
