summaryrefslogtreecommitdiff
path: root/devdocs/elisp/sequence-type.html
blob: 7f21449066bec915afdad3449aa30a1b9bd5f162 (plain)
1
2
3
4
5
6
 <h4 class="subsection">Sequence Types</h4> <p>A <em>sequence</em> is a Lisp object that represents an ordered set of elements. There are two kinds of sequence in Emacs Lisp: <em>lists</em> and <em>arrays</em>. </p> <p>Lists are the most commonly-used sequences. A list can hold elements of any type, and its length can be easily changed by adding or removing elements. See the next subsection for more about lists. </p> <p>Arrays are fixed-length sequences. They are further subdivided into strings, vectors, char-tables and bool-vectors. Vectors can hold elements of any type, whereas string elements must be characters, and bool-vector elements must be <code>t</code> or <code>nil</code>. Char-tables are like vectors except that they are indexed by any valid character code. The characters in a string can have text properties like characters in a buffer (see <a href="text-properties">Text Properties</a>), but vectors do not support text properties, even when their elements happen to be characters. </p> <p>Lists, strings and the other array types also share important similarities. For example, all have a length <var>l</var>, and all have elements which can be indexed from zero to <var>l</var> minus one. Several functions, called sequence functions, accept any kind of sequence. For example, the function <code>length</code> reports the length of any kind of sequence. See <a href="sequences-arrays-vectors">Sequences Arrays Vectors</a>. </p> <p>It is generally impossible to read the same sequence twice, since sequences are always created anew upon reading. If you read the read syntax for a sequence twice, you get two sequences with equal contents. There is one exception: the empty list <code>()</code> always stands for the same object, <code>nil</code>. </p><div class="_attribution">
  <p class="_attribution-p">
    Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
    <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Sequence-Type.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Sequence-Type.html</a>
  </p>
</div>