diff options
Diffstat (limited to 'devdocs/elisp/bool_002dvectors.html')
| -rw-r--r-- | devdocs/elisp/bool_002dvectors.html | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/devdocs/elisp/bool_002dvectors.html b/devdocs/elisp/bool_002dvectors.html new file mode 100644 index 00000000..c91cd969 --- /dev/null +++ b/devdocs/elisp/bool_002dvectors.html @@ -0,0 +1,45 @@ + <h3 class="section">Bool-vectors</h3> <p>A bool-vector is much like a vector, except that it stores only the values <code>t</code> and <code>nil</code>. If you try to store any non-<code>nil</code> value into an element of the bool-vector, the effect is to store <code>t</code> there. As with all arrays, bool-vector indices start from 0, and the length cannot be changed once the bool-vector is created. Bool-vectors are constants when evaluated. </p> <p>Several functions work specifically with bool-vectors; aside from that, you manipulate them with same functions used for other kinds of arrays. </p> <dl> <dt id="make-bool-vector">Function: <strong>make-bool-vector</strong> <em>length initial</em> +</dt> <dd><p>Return a new bool-vector of <var>length</var> elements, each one initialized to <var>initial</var>. </p></dd> +</dl> <dl> <dt id="bool-vector">Function: <strong>bool-vector</strong> <em>&rest objects</em> +</dt> <dd><p>This function creates and returns a bool-vector whose elements are the arguments, <var>objects</var>. </p></dd> +</dl> <dl> <dt id="bool-vector-p">Function: <strong>bool-vector-p</strong> <em>object</em> +</dt> <dd><p>This returns <code>t</code> if <var>object</var> is a bool-vector, and <code>nil</code> otherwise. </p></dd> +</dl> <p>There are also some bool-vector set operation functions, described below: </p> <dl> <dt id="bool-vector-exclusive-or">Function: <strong>bool-vector-exclusive-or</strong> <em>a b &optional c</em> +</dt> <dd><p>Return <em>bitwise exclusive or</em> of bool vectors <var>a</var> and <var>b</var>. If optional argument <var>c</var> is given, the result of this operation is stored into <var>c</var>. All arguments should be bool vectors of the same length. </p></dd> +</dl> <dl> <dt id="bool-vector-union">Function: <strong>bool-vector-union</strong> <em>a b &optional c</em> +</dt> <dd><p>Return <em>bitwise or</em> of bool vectors <var>a</var> and <var>b</var>. If optional argument <var>c</var> is given, the result of this operation is stored into <var>c</var>. All arguments should be bool vectors of the same length. </p></dd> +</dl> <dl> <dt id="bool-vector-intersection">Function: <strong>bool-vector-intersection</strong> <em>a b &optional c</em> +</dt> <dd><p>Return <em>bitwise and</em> of bool vectors <var>a</var> and <var>b</var>. If optional argument <var>c</var> is given, the result of this operation is stored into <var>c</var>. All arguments should be bool vectors of the same length. </p></dd> +</dl> <dl> <dt id="bool-vector-set-difference">Function: <strong>bool-vector-set-difference</strong> <em>a b &optional c</em> +</dt> <dd><p>Return <em>set difference</em> of bool vectors <var>a</var> and <var>b</var>. If optional argument <var>c</var> is given, the result of this operation is stored into <var>c</var>. All arguments should be bool vectors of the same length. </p></dd> +</dl> <dl> <dt id="bool-vector-not">Function: <strong>bool-vector-not</strong> <em>a &optional b</em> +</dt> <dd><p>Return <em>set complement</em> of bool vector <var>a</var>. If optional argument <var>b</var> is given, the result of this operation is stored into <var>b</var>. All arguments should be bool vectors of the same length. </p></dd> +</dl> <dl> <dt id="bool-vector-subsetp">Function: <strong>bool-vector-subsetp</strong> <em>a b</em> +</dt> <dd><p>Return <code>t</code> if every <code>t</code> value in <var>a</var> is also <code>t</code> in <var>b</var>, <code>nil</code> otherwise. All arguments should be bool vectors of the same length. </p></dd> +</dl> <dl> <dt id="bool-vector-count-consecutive">Function: <strong>bool-vector-count-consecutive</strong> <em>a b i</em> +</dt> <dd><p>Return the number of consecutive elements in <var>a</var> equal <var>b</var> starting at <var>i</var>. <code>a</code> is a bool vector, <var>b</var> is <code>t</code> or <code>nil</code>, and <var>i</var> is an index into <code>a</code>. </p></dd> +</dl> <dl> <dt id="bool-vector-count-population">Function: <strong>bool-vector-count-population</strong> <em>a</em> +</dt> <dd><p>Return the number of elements that are <code>t</code> in bool vector <var>a</var>. </p></dd> +</dl> <p>The printed form represents up to 8 boolean values as a single character: </p> <div class="example"> <pre class="example">(bool-vector t nil t nil) + ⇒ #&4"^E" +(bool-vector) + ⇒ #&0"" +</pre> +</div> <p>You can use <code>vconcat</code> to print a bool-vector like other vectors: </p> <div class="example"> <pre class="example">(vconcat (bool-vector nil t nil t)) + ⇒ [nil t nil t] +</pre> +</div> <p>Here is another example of creating, examining, and updating a bool-vector: </p> <div class="example"> <pre class="example">(setq bv (make-bool-vector 5 t)) + ⇒ #&5"^_" +(aref bv 1) + ⇒ t +(aset bv 3 nil) + ⇒ nil +bv + ⇒ #&5"^W" +</pre> +</div> <p>These results make sense because the binary codes for control-_ and control-W are 11111 and 10111, respectively. </p><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/Bool_002dVectors.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Bool_002dVectors.html</a> + </p> +</div> |
