diff options
Diffstat (limited to 'devdocs/elisp/vector-functions.html')
| -rw-r--r-- | devdocs/elisp/vector-functions.html | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/devdocs/elisp/vector-functions.html b/devdocs/elisp/vector-functions.html new file mode 100644 index 00000000..a65f54d3 --- /dev/null +++ b/devdocs/elisp/vector-functions.html @@ -0,0 +1,47 @@ + <h3 class="section">Functions for Vectors</h3> <p>Here are some functions that relate to vectors: </p> <dl> <dt id="vectorp">Function: <strong>vectorp</strong> <em>object</em> +</dt> <dd> +<p>This function returns <code>t</code> if <var>object</var> is a vector. </p> <div class="example"> <pre class="example">(vectorp [a]) + ⇒ t +(vectorp "asdf") + ⇒ nil +</pre> +</div> </dd> +</dl> <dl> <dt id="vector">Function: <strong>vector</strong> <em>&rest objects</em> +</dt> <dd> +<p>This function creates and returns a vector whose elements are the arguments, <var>objects</var>. </p> <div class="example"> <pre class="example">(vector 'foo 23 [bar baz] "rats") + ⇒ [foo 23 [bar baz] "rats"] +(vector) + ⇒ [] +</pre> +</div> </dd> +</dl> <dl> <dt id="make-vector">Function: <strong>make-vector</strong> <em>length object</em> +</dt> <dd> +<p>This function returns a new vector consisting of <var>length</var> elements, each initialized to <var>object</var>. </p> <div class="example"> <pre class="example">(setq sleepy (make-vector 9 'Z)) + ⇒ [Z Z Z Z Z Z Z Z Z] +</pre> +</div> </dd> +</dl> <dl> <dt id="vconcat">Function: <strong>vconcat</strong> <em>&rest sequences</em> +</dt> <dd> + <p>This function returns a new vector containing all the elements of <var>sequences</var>. The arguments <var>sequences</var> may be proper lists, vectors, strings or bool-vectors. If no <var>sequences</var> are given, the empty vector is returned. </p> <p>The value is either the empty vector, or is a newly constructed nonempty vector that is not <code>eq</code> to any existing vector. </p> <div class="example"> <pre class="example">(setq a (vconcat '(A B C) '(D E F))) + ⇒ [A B C D E F] +(eq a (vconcat a)) + ⇒ nil +</pre> +<pre class="example">(vconcat) + ⇒ [] +(vconcat [A B C] "aa" '(foo (6 7))) + ⇒ [A B C 97 97 foo (6 7)] +</pre> +</div> <p>The <code>vconcat</code> function also allows byte-code function objects as arguments. This is a special feature to make it easy to access the entire contents of a byte-code function object. See <a href="byte_002dcode-objects">Byte-Code Objects</a>. </p> <p>For other concatenation functions, see <code>mapconcat</code> in <a href="mapping-functions">Mapping Functions</a>, <code>concat</code> in <a href="creating-strings">Creating Strings</a>, and <code>append</code> in <a href="building-lists">Building Lists</a>. </p> +</dd> +</dl> <p>The <code>append</code> function also provides a way to convert a vector into a list with the same elements: </p> <div class="example"> <pre class="example">(setq avector [1 two (quote (three)) "four" [five]]) + ⇒ [1 two '(three) "four" [five]] +(append avector nil) + ⇒ (1 two '(three) "four" [five]) +</pre> +</div><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 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/Vector-Functions.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Vector-Functions.html</a> + </p> +</div> |
