summaryrefslogtreecommitdiff
path: root/devdocs/elisp/vectors.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/vectors.html
new repository
Diffstat (limited to 'devdocs/elisp/vectors.html')
-rw-r--r--devdocs/elisp/vectors.html13
1 files changed, 13 insertions, 0 deletions
diff --git a/devdocs/elisp/vectors.html b/devdocs/elisp/vectors.html
new file mode 100644
index 00000000..c1c2653f
--- /dev/null
+++ b/devdocs/elisp/vectors.html
@@ -0,0 +1,13 @@
+ <h3 class="section">Vectors</h3> <p>A <em>vector</em> is a general-purpose array whose elements can be any Lisp objects. (By contrast, the elements of a string can only be characters. See <a href="strings-and-characters">Strings and Characters</a>.) Vectors are used in Emacs for many purposes: as key sequences (see <a href="key-sequences">Key Sequences</a>), as symbol-lookup tables (see <a href="creating-symbols">Creating Symbols</a>), as part of the representation of a byte-compiled function (see <a href="byte-compilation">Byte Compilation</a>), and more. </p> <p>Like other arrays, vectors use zero-origin indexing: the first element has index 0. </p> <p>Vectors are printed with square brackets surrounding the elements. Thus, a vector whose elements are the symbols <code>a</code>, <code>b</code> and <code>a</code> is printed as <code>[a b a]</code>. You can write vectors in the same way in Lisp input. </p> <p>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 not evaluate or even examine the elements of the vector. See <a href="self_002devaluating-forms">Self-Evaluating Forms</a>. Vectors written with square brackets should not be modified via <code>aset</code> or other destructive operations. See <a href="mutability">Mutability</a>. </p> <p>Here are examples illustrating these principles: </p> <div class="example"> <pre class="example">(setq avector [1 two '(three) "four" [five]])
+ ⇒ [1 two '(three) "four" [five]]
+(eval avector)
+ ⇒ [1 two '(three) "four" [five]]
+(eq avector (eval avector))
+ ⇒ t
+</pre>
+</div><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/Vectors.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Vectors.html</a>
+ </p>
+</div>